Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
115 views

Chapter 15 Django Based Web Application Part Iieng PDF

This document discusses Django-based web applications. It provides an overview of creating a Django project and app, registering the app, generating templates and adding views. It then discusses adding components to a webpage, using GET and POST methods to send data from the webpage to a server, and saving inputted data to a CSV file. Templates, views, URLs and the Django Template Language are demonstrated through an example student registration application.
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)
115 views

Chapter 15 Django Based Web Application Part Iieng PDF

This document discusses Django-based web applications. It provides an overview of creating a Django project and app, registering the app, generating templates and adding views. It then discusses adding components to a webpage, using GET and POST methods to send data from the webpage to a server, and saving inputted data to a CSV file. Templates, views, URLs and the Django Template Language are demonstrated through an example student registration application.
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/ 17

Django Based Web Application

Part - II
CBSE Syllabus Based
Class -12
CHAPTER -15 CS
CHAPTER-9 IP
By-
Neha Tyagi
PGT CS
KV 5 Jaipur II Shift
Blog- www.pythontrends.wordpress.com
YouTube Channel : “Python Trends”
E-mail: python.kvs@gmail.com
Neha Tyagi, KV 5 Jaipur II Shift
What we learnt in Part-I?
• First we will take a review of what we learnt in first part.
• We learnt creation of Project and app.
• Registering App in to Project.
• Generate webpages in Templates and add an entry in views.py.
• Setting path in url.py.
• Running Django server.
• Opening of pages on web browser by giving URL.

ClassXII

CLassXII student Manage.py

__init__.py Settings.py Urls.py Wsgi.py

Admin.py Apps.py Models.py Tests.py


migration __init__.py Views.py

Neha Tyagi, KV 5 Jaipur II Shift


Creation and Saving of Webpage
• Create a webpage firstpage.html in Template folder.

• We will make its entry in a function in


views.py.

Neha Tyagi, KV 5 Jaipur II Shift


Writing logic in Views.py
• Our next step is to write function for html page in views.py.
• In this file, we used to keep all those function which we want to
execute.
• Views works for rendering a page. For this, from student folder,
open the views.py in IDLE and create a view i.e. we will write a
function which will render and return the existing html file.

Neha Tyagi, KV 5 Jaipur II Shift


Setting views in Urls.py
• Now we will access inner project folder (ClassXII) and add
following code in urls.py.

here firstpage is the name that we will give on


web page (http://127.0.0.1:8000/firstpage)

• Now save the file.


• And run django server.

Neha Tyagi, KV 5 Jaipur II Shift
Displaying Webpage
• At last, we will open the web browser and will write the url of
our html page.

Neha Tyagi, KV 5 Jaipur II Shift


Django Based web Applications Part -2
• In this part we will learn to add various
components on a web page and also learn the
method to send the data from webpage to server.
• Use of Get Method and POST Method.
• Saving data inputted on a Webpage to a csv file.
• Little DTL (Django Template Language) for this
purpose.
• We will develop a small application for this.

Neha Tyagi, KV 5 Jaipur II Shift


Example
• Lets take an example.

We will use
stud.csv file to
store data.
KVS

KVS teacher Manage.py Template

__init__.py Settings.py Urls.py Wsgi.py


first.html Stuentry.html

migration __init__.py Admin.py Apps.py Models.py Tests.py Views.py

Neha Tyagi, KV 5 Jaipur II Shift


Views.py file

first.html
file will
open by
this.

studentry.html
file will open by
this.

Neha Tyagi, KV 5 Jaipur II Shift


urls.py file

runserver

Neha Tyagi, KV 5 Jaipur II Shift


first.html file

See these names


carefully. These are the
names which were sent
from views via
dictionary.

DTL syntax

For Navigation

Neha Tyagi, KV 5 Jaipur II Shift


stuenytry.html file

Neha Tyagi, KV 5 Jaipur II Shift


Opening First.html in browser

This data is sent by show() of


views.py , one by even variable
and other by name variable.

Neha Tyagi, KV 5 Jaipur II Shift


Opening stuentry.html in browser

Neha Tyagi, KV 5 Jaipur II Shift


What is HTTP?
• http is a collection of the protocols which carried
out the communication between client and server.
• They work as request-response protocol between
client and server.
• A web browser is a client and any application
which host the website can be a server.
• Two methods are used for this GET and POST.
• We have used both the methods in this chapter.

Neha Tyagi, KV 5 Jaipur II Shift


Django Template Language
• In this chapter we have used some DTL.
• For detailed information of DTL, click the following
links-

https://docs.djangoproject.com/en/2.2/ref/templates/language/

https://www.tutorialspoint.com/django/django_template_system.htm

Neha Tyagi, KV 5 Jaipur II Shift


Thank you

please follow us on our blog-


www.pythontrends.wordpress.com

Neha Tyagi, KV 5 Jaipur II Shift

You might also like