Django login and logout¶
In settings.py, add:
LOGIN_URL = '/login/'
In urls.py, add:
urlpatterns += patterns('', (r'^login/$', django.contrib.auth.views.login), (r'^logout/$', django.contrib.auth.views.logout), )
Create a template “registration/login.html”, copying from the sample in the doc
Add a logout link to your base template:
<a href="/logout/">Logout</a>
On each view function where users should be logged in before using, add the decorator:
@login_required def myview(...)