I'm trying to add a "keep me logged in" check box to Django's default login view.
Here is what I'm doing:
urls.py
url(r'^login/$',
myuser_login,
{'template_name': 'app_registration/login.html', 'authentication_form': MyAuthenticationForm},
name='auth_login',
),
views.py
from django.contrib.auth.views import login
def myuser_login(request, *args, **kwargs):
if request.method == 'POST':
if not request.POST.get('remember', None):
request.session.set_expiry(0)
login(request, *args, **kwargs)
So basically, I'm trying to add additional information to my own view and just simply call Django's default login function. When I do this, I get this error:
ValueError at /accounts/login/
The view app_registration.views.myuser_login didn't return an HttpResponse object.
I checked the Django source code, and the default contrib.auth.views.login function obviously returns an HttpResponse.
What should I do :(((?
Thanks!!
All django views must return HttpResponse
. Your view isn't returning anything.
You should return like this
def myuser_login(request, *args, **kwargs):
if request.method == 'POST':
if not request.POST.get('remember', None):
request.session.set_expiry(0)
return login(request, *args, **kwargs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With