Articles → DJANGO → Add New Pages In Django Project
Add New Pages In Django Project
Steps Of Adding New Pages
- Create a new template
- Create a new function in views.py for about page.
- Add an entry in urls.py
Create A New Template
<html>
<head></head>
<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>
</html>
Create A New Function In Views.Py 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 Urls.Py
from django.contrib
import admin
from django.urls
import path
from TestModule.views
import home
from TestModule.views
import about
urlpatterns = [
path('admin/', admin.site.urls),
path('', home),
path('about/', about),
]
Output
Click to Enlarge