3. Setting up the Login and Logout Views

In this section we’ll set up the provided login and logout views to allow for logging in using basic username and password authentication.

3.1. URL Routing

You can add the login and logout views to your url configuration by including the newauth.urls module.

urlpatterns = [
    # ...
    url(r'^account/', include('newauth.urls')),
    # ...
]

3.2. Customizing the login form

The provided login view can use any form class that extends the BaseAuthForm class. You can specify the form class by passing it in the authentication_form argument to the login <newauth.views.login() view.

urlpatterns = [
    # ...
    url(r'^login/$', 'newauth.views.login', name='newauth_login', kwargs={
        'authentication_form': MyLoginForm,
    }),
    # ...
]

In the next section we’ll discuss how to limit access to views to logged-in users.