O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

19.5.3 Using Django’s Views to Make Login and Logout Pages

If we pop open Django’s source code, we can browse to django/contrib/auth/views.py and look at the definition of login(), shown in Example 19.30.

Example 19.30: Python Code

# django/contrib/auth/views.py def login(request, template_name='registration/login.html',            redirect_field_name=REDIRECT_FIELD_NAME,            authentication_form=AuthenticationForm,            current_app=None, extra_context=None):

The parameter we’re interested in overriding is template_name.

To start, we should import all of the tools we will need for our URL patterns, as shown in Example 19.31.

Example 19.31: Project Code

user/urls.py in 07122a7dd9

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required