Creating an about page
Now that we learned how to create a simple page, let’s repeat the process to create the about page. We will follow these three steps:
- Configure the about URL.
- Define the about function.
- Create the about template.
Let’s start.
Configuring the about URL
In /home/urls.py
, add the following path in bold:
from django.urls import path from . import views urlpatterns = [ path('', views.index, name='home.index'), path('about', views.about, name='home.about'), ]
So, if a URL matches the /about
path, it will execute the about
function defined in the views
file.
Defining about function
In /home/views.py
, add the following in bold:
from django.shortcuts import render def index(request): return render(request, 'home/index.html') def about(request): return render(request, ...