0% found this document useful (0 votes)
5 views3 pages

s

The document outlines a Django web application with views for home, about, and contact pages, using both ordered and unordered lists to display fruits and students. It includes HTML templates for each page and a URL configuration to route requests to the appropriate views. The code contains some syntax errors that need correction for proper functionality.

Uploaded by

Gowdru Hudga0127
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

s

The document outlines a Django web application with views for home, about, and contact pages, using both ordered and unordered lists to display fruits and students. It includes HTML templates for each page and a URL configuration to route requests to the appropriate views. The code contains some syntax errors that need correction for proper functionality.

Uploaded by

Gowdru Hudga0127
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ORDERED AND UNORDERD LIST PROGRAM

 view.py

from django.shortcuts import render

def home(request):
fruits = [‘orange’ , ’apple’ , ’mango’]
students = [‘john’ , ‘jani’ , ‘janardhan’]
context={‘students’ : students , ‘fruits’ : fruits}
return render (request, ‘home.html’, context)

 home.html

<HTML>
<body>
<h1>FRUITS</h1>
<ul>
{% for fruit in fruits %}
<li>{{fruit}}</li>
{% end for%}
</ul>
<h1>STUDENTS</h1>
<ol>
{% for student in students %}
<li>{{student}}</li>
{% end for%}
</ul>
</body>
</html>

 urls.py

from django.urls import path


from myapp import views

urlpa erns = [
path(‘home/', views.home),
]
LAYOUT PROGRAM

 layout.html

<HTML>
<TITLE>{% block tle %} {% end block %}</TITLE>
<body>
<a href = ‘home/’>HOME</a>
<a href = ‘about/’>ABOUT</a>
<a href = ‘contact/’>CONTACT</a>
<sec on>{% block content %} {% end block %}
</body>
</html>

 about.html

{% extends ‘myapp/layout.html’ %}
{% block tle %}ABOUT {% end block %}
{% block content %} THIS IS ABOUT PAGE{% end block %}

 contact.html

{% extends ‘myapp/layout.html’ %}
{% block tle %}CONTACT {% end block %}
{% block content %} THIS IS CONTACT PAGE{% end block %}

 home.html

{% extends ‘myapp/layout.html’ %}
{% block tle %}HOME {% end block %}
{% block content %} THIS IS HOME PAGE{% end block %
 view.py

from django.shortcuts import render

def home(request):
retrun render(request , ‘myapp/home.html’)

def about(request):
retrun render(request , ‘myapp/about.html’)

def contact(request):
retrun render(request , ‘myapp/contact.html’)

 urls.py

from django.urls import path


from myapp import views

urlpa erns = [
path(‘home/', views.home),
path(‘about/', views.about),
path(‘contact/', views.contact),
]

You might also like