Creating a login page
Let’s implement the login page. This time, we won’t use Django forms; we will create our own HTML form (to learn a new approach). Let’s follow the following steps:
- Configure a login URL.
- Define the
login
function. - Create an accounts login template.
- Add a link to the base template.
- Redirect a registered user to the login page.
We’ll see these steps to create a login page, in depth, in the next few subsections.
Configuring a login URL
In /accounts/urls.py
, add the following path in bold:
from django.urls import path from . import views urlpatterns = [ path('signup', views.signup, name='accounts.signup'), path('login/', views.login, name='accounts.login'), ]
So, if a URL matches the /accounts/login
path, it will execute the login
function defined in the views
file.
Now that we have the new path, let’...