You are here

Multi Page Website in Django

Project – Multi page website

We will following steps in creating a multi-page website in Django

Steps-1: Create views.html

Step-2: create path in urls.py

Step-3: create a template folder in external folder

Step-4: create html file index.html and contact.html files in the template folder

Step-5 : run the project in the browser

 

Steps-1: Create views.html

From django.shortcuts import render

def home(request):

            return render(request,’index.html’)

def contact(request):

            return render(request,’contact.html’)

Step-2: create path in urls.py

from . import views

urlpatterns = [

            path(‘admin/’, admin.site.urls),

path(‘ ‘, views.home),

path(‘about/’, views.contact, name=’contact’),      #check name=’anyname’

]

Step-3: create a template folder in external folder

Right click external folder and right click to create folder, name it as template

Step-4: create html file index.html and contact.html files in the template folder

<!DOCTYPE html>

<html lang=”en” dir=”ltr”>

<head>

            <meta charset=”utf-8”>

<title> home </title>

</head>

</body>

<h1> This is my first page</h1>

<h3> list </h3>

<ul>

            <li> views.py   </li>

            <li> urls.py   </li>

            <li> template   </li>

            <li> settings.py   </li>

</ul>

</body>

</html>

Create another html file in template folder

<!DOCTYPE html>

<html lang=”en” dir=”ltr”>

<head>

            <meta charset=”utf-8”>

<title> contact </title>

</head>

</body>

<h1> This is my About  page</h1>

            <a href=”contact.html”>Click here to go to contact page</a>

</body>

</html>

Step-5 : run the project in the browser

Leave a Reply

Top
error: Content is protected !!