Create Five Method and Pages in Django Framework

0
1 ) Create App

2) Create urls.py and define four different path
from django.urls import path
from . import views
urlpatterns = [

    path('', views.index, name='index'),
    path('about', views.about, name='about'),
    path('contact', views.contact, name='contact'),
    path('service', views.service, name='service')
  


 ]

3 create views.py and define method
from django.shortcuts import render

def index(request):
    return render(request,"siteapp/index.html")
def about(request):
    return render(request,"siteapp/about.html")
def contact(request):
    return render(request,"siteapp/contact.html")
def service(request):
    return render(request,"siteapp/service.html")           

4 create templates/appname and create four different html file


index.html:-

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="">Home</a>
    <a href="about">About us</a>
    <a href="contact">Contact us</a>
    <a href="service">Services</a>
<h1>Welcome in Home page</h1>
</body>
</html>

about.html
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="">Home</a>
    <a href="about">About us</a>
    <a href="contact">Contact us</a>
    <a href="service">Services</a>
<h1>welcome in about page</h1>
</body>
</html>

service.html
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="">Home</a>
    <a href="about">About us</a>
    <a href="contact">Contact us</a>
    <a href="service">Services</a>
<h1>Welcome in Services Page</h1>
</body>
</html>

contact.html

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="">Home</a>
    <a href="about">About us</a>
    <a href="contact">Contact us</a>
    <a href="service">Services</a>
<h1>Welcome in Contact Page</h1>
</body>
</html>

5) register app in setting and urls.py of base app


6) create Style.css


css means cascading style sheet it is used to provide set of properties to define HTML element.

 create css file under static/css/filename

 use <link> tag to link css file in HTML page

it will be always declared under
 <head>

<link href="/static/css/style.css" type="text/css" rel="stylesheet" />

</head>



 

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)