0% found this document useful (0 votes)
22 views6 pages

FD Manual 1-3

Uploaded by

Deepika
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)
22 views6 pages

FD Manual 1-3

Uploaded by

Deepika
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/ 6

1.

Develop a Django app that displays current date and time in server

views.py File

urls.py File

Output
2. Develop a Django app that displays date and time four hours ahead and four
hours before as an offset of current date and time in the server.
views.py File

urls.py File

Output
Steps to be followed while third program
3. Develop a simple Django app that displays an unordered list of fruits and
ordered list of selected students for an event

Index.html

<html>
</head>
<title>Home Page</title>
</head>
<body>

<h1>List of Fruits</h1>

<ul>
{% for item in fruit_list %}
<li>{{item}}</li>
{%endfor%}
</ul>

<h1>List of students</h1>

<ul>
{% for student in student_list %}
{%if student.score > 75%}
<li>{{student.name}}</li>
{%endif%}
{%endfor%}
</ul>
</body>
</html>

View.py

from django.http import HttpResponse


from django.shortcuts import render

def homepage(request):
fruits=['Apple','Banana','Orange','Pineapple']

students = [
{'name': 'Harish', 'score': 85},
{'name': 'Briana', 'score': 70},
{'name': 'John', 'score': 95},
{'name': 'Arul', 'score': 60},
]

context={'fruit_list':fruits,'student_list':students,}
return render(request,"index.html",context)
ulrs.py

from django.contrib import admin


from django.urls import path
from .views import homepage

urlpatterns = [
path('admin/', admin.site.urls),
path('home/',homepage),
]

Output

You might also like