22👍
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
5👍
If you do not want to link the LOGIN_URL
to the “view” (you can change on other), then you can link to the named URL in settings.py
:
from django.core.urlresolvers import reverse_lazy
LOGIN_URL = reverse_lazy('login')
where “login” is something like:
url(r'^accounts/login/$', 'my_app.view.Login', name='login'),
then, if you change the view on the other, you don’t need to make changes in settings.py
- Pycharm Django Debugging is really slow
- Have a url that accepts all characters
- (gcloud.app.deploy) Error Response: [7] Access Not Configured. Cloud Build has not been used in project
- Make browser submit additional HTTP-Header if click on hyperlink
5👍
Assuming you’ve set the path name in urls.py
, you can use 'application_name:view_name'
as the LOGIN_URL
value in settings.py
, like so:
application/urls.py
...
path('login/', views.login, name='login'),
...
project/settings.py
LOGIN_URL = 'application:login'
https://docs.djangoproject.com/en/2.1/ref/settings/#login-url
2👍
Django 2.1.5
django.urls import reverse_lazy
LOGIN_URL = reverse_lazy('namespace of any url used in your project ')
- Django is very slow on my machine
- Django reverse error: NoReverseMatch
- Does Django have a Windows 7 Installer? I couldn't find one and theres little mention of Windows
1👍
If you have the view in the project root ( not inside an app ) you just specify the view name in settings.py:
…
LOGIN_URL = 'login'
…
- Django: Check for related objects and whether it contains data
- Enable PK based filtering in Django Graphene Relay while retaining Global IDs
- Django Rest Framework: Serialize data from nested json fields to plain object