Implementing the login functionality
Having implemented signup and logout, let's now implement login:
- Create a login path in
/accounts/urls.py
:… urlpatterns = [ path('signupaccount/', views.signupaccount, name='signupaccount'), path('logout/', views.logoutaccount, name='logoutaccount'), path('login/', views.loginaccount, name='loginaccount'), ]
- In
/accounts/views.py
, implementloginaccount
with the following in bold:… ... from django.contrib.auth.models import User from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import login, logout, authenticate ... def loginaccount(request): ...