.. index:: django; login .. index:: django; logout Django login and logout ======================= `Django doc `_ * 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:: Logout * On each view function where users should be logged in before using, add the decorator:: @login_required def myview(...)