The tag in question:
< a href="{% url django.contrib.auth.views.login %}">Login< /a>
URLConf:
from django.contrib.auth import views <br />
...<br />
(r'^login/$',views.login, {'redirect_field_name' : '/' })
<br />...
it's better to use named urls, they save a lot of maintenance work in the future and typing in the first place.
if you keep name of the url the same, you can rename view function, move it to a different app, etc. you won't need to change templates or other places using this url at all.
in urls.py:
url(r'^login/',path.to.view,name='login',...)
in templates:
<a href="{%url login%}">login here</a>
in views:
login_url = reverse('login')
For some reason it didn't like the way I was importing it.
Solution:
from django.contrib.auth.views import login
(r'^login', login, etc.)
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