1👍
You can specify the URL users not logged in will be redirected to by setting LOGIN_URL
in your settings.py
globally. (Of course you can also override that setting where ever you apply the decorator if you want to.)
According to the docs, you can also specify named url patterns, e.g., LOGIN_URL = 'myapp:login'
, and view function names, e.g., LOGIN_URL = 'myapp.login_view'
.
From the docs:
LOGIN_URL
Default:
'/accounts/login/'
The URL where requests are redirected for login, especially when using the
login_required()
decorator.This setting also accepts view function names and named URL patterns which can be used to reduce configuration duplication since you don’t have to define the URL in two places (settings and URLconf).
For reference:
0👍
You can set the login URL of your site in your settings.py file as LOGIN_URL. Then, you don’t have to worry about changing it in the different places.
- [Answer]-Trouble with django upload_to callable
- [Answer]-Can't test changes to the database through Django Test
- [Answer]-Serve static files in Django. Need explanation
- [Answer]-Deploy Django on Amazon Elastic Beanstalk. LOGGING_INFO environment variable not set
- [Answer]-Model not available during datamigration