def friend_login(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user:
if user.is_active:
# the User model is valid and active, so we can log the user in
print 'User is active'
login(request, user)
return HttpResponseRedirect(reverse('main:index'))
else:
# An inactive account was used - no logging in!
print 'User is inactive'
return render(request, 'friends/inactive.html', {'user':user})
else:
# Bad login credentials
return HttpResponse("Invalid login details supplied.")
else:
# Not a POST, so simply display the login form
return render(request, 'friends/login.html', {})
签名由 网易邮箱大师 定制
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8821e5bc-0a14-47e2-82bd-8b229daaf50d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.