Articles → DJANGO → Add new pages in Django project

Add new pages in Django project

Steps of adding new pages

Create a new template



<body>Welcome to Gyan Sangrah: A one stop shop for people preparing for technical interviews. Gyansangrah is an online resource comprising all the possible questions you may face during your technical interview round. Gyansangrah also provides you with live examples to make concepts easier to understand.</body>


Create a new function in for about page

def about(request):
  return render(request, "about.html", {})

from django.http
import HttpResponse
from django.shortcuts
import render

# Create your views here.
def home(request):
  return render(request, "FirstTemplate.html", {
    "numbers": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

def about(request):
  return render(request, "about.html", {})  

Add an entry in

"MyFirstProject URL Configuration

The `urlpatterns`
list routes URLs to views.For more information please see:
  https: //
  Function views
1. Add an
import: from my_app
import views
2. Add a URL to urlpatterns: path('', views.home, name = 'home')
Class - based views
1. Add an
import: from other_app.views
import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name = 'home')
Including another URLconf
1. Import the include()
function: from django.urls
import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
from django.contrib
import admin
from django.urls
import path
from TestModule.views
import home
from TestModule.views
import about

urlpatterns = [
  path('', home),
  path('about/', about),



Picture showing the new about page in Django

Click to Enlarge

Posted By  -  Karan Gupta
Posted On  -  Tuesday, June 18, 2019


Your Email Id  
Query/FeedbackCharacters remaining 250