Login and logout views

Edit the urls.py of your account application, like this:

from django.urls import pathfrom django.contrib.auth import views as auth_viewsfrom . import viewsurlpatterns = [    # previous login view    # path('login/', views.user_login, name='login'),    path('login/', auth_views.LoginView.as_view(), name='login'),    path('logout/', auth_views.LogoutView.as_view(), name='logout'),]

We comment out the URL pattern for the user_login view we have created previously to use the LoginView view of Django's authentication framework. We also add a URL pattern for the  LogoutView view.

Create a new directory inside the templates directory of your account application and name it registration. This is the default path where the Django authentication ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.