Issue
def loggin(req):
if req.user.is_authenticated:
return redirect('home')
if req.POST:
username=req.POST['username']
password=req.POST['password']
usr = authenticate(req,username=username,password=password)
if usr is not None:
login(req,usr)
return redirect(reverse('home'))
return render(req,'cart/login.html')
def home(req):
if req.user.is_authenticated:
name=req.user
context = {
'name':name,
}
return render(req,'cart/home.html',context)
My settings.py are fine and have no error in code but after successful get logged in redirection to home view shows AnonymousUser.I dont know what i am doing wrong.
Solution
I think it is becouse your are sending the user object instead than the name
req.user.username
Then you have a typo
if req.method == 'POST':
Answered By - Paolo Vezzola
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.