As of Django 1.5, you can set LOGIN_URL to a view function name, but I haven't been able to figure out how to specify it correctly.
LOGIN_URL = my_app.views.sign_in
...does not work. I get the error,
ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Django computes this url in django.contrib.auth.views:redirect_to_login function as:
resolved_url = resolve_url(login_url or settings.LOGIN_URL)
Therefore you should set it as string:
LOGIN_URL = 'my_app.views.sign_in'
Also in settings.py you can use reverse_lazy function:
from django.core.urlresolvers import reverse_lazy
LOGIN_URL = reverse_lazy('my_app.views.sign_in')
https://docs.djangoproject.com/en/1.5/ref/urlresolvers/#reverse-lazy
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