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

Chapter-9 Creating A Django Based Basic Web Application

The document discusses creating a basic Django web application. It explains that Django is a Python-based web framework that prevents repetition of work. It provides steps to install Django and create a project, apps, models, templates, and views. The models define how data is stored and processed. Templates are created for each app and views receive requests and return responses in the form of templates.

Uploaded by

Swarnim Jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views

Chapter-9 Creating A Django Based Basic Web Application

The document discusses creating a basic Django web application. It explains that Django is a Python-based web framework that prevents repetition of work. It provides steps to install Django and create a project, apps, models, templates, and views. The models define how data is stored and processed. Templates are created for each app and views receive requests and return responses in the form of templates.

Uploaded by

Swarnim Jain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter-9

Creating a Django based Basic Web Application

Introduction :Django is a web framework that is used along with Python


to develop dynamic websites.

Web Framework – A Web Framework is a software tool that provides a


way to build and run dynamic websites and web-enabled applications.

How Web, Websites and Web-application Work ?

Web works in the form of client-server architecture. Our web


browser act as a client program (web client or the front-end), and
the web server with which it interact is the server (the backend).

The client (web browser) work on the web mostly with HTTP protocol.
The client make an HTTP request , which the (web) server responds to
in the form of a response called HTTP response.

The client mostly make these two types of HTTP requests:


Introducing Django: Django is python based free and open source web
application framework. It prevents repetition of work.

Installing Django:

To install Django on Windows , follow the steps given below:

(i) Connect to internet

(ii) Start cmd (Windows 7) or Windows Power Shell (Windows 10) in


administrator mode.

(iii) go to the folder where you want to install virtual environment by


using CD command.

(iv) type the following command to download and install virtual


environment
(v) now type following command

(vi) Nowactivate virtual environment by giving activate command.

(vii) Once activated, install Django :


Creating a Project in Django:
Creating Apps of a Django Project :

First go inside the outer project folder online_shop (because


manage.py reside in it) and then issue command:

Register apps – Register apps with project after creating them.


Open inner project-name folder’s setting.py file and add apps names in
the INSTALLED APPS list.

Creating Models : Models in Django refer to the way data is stored and
processed. The data model for an app is defined inside model.py file of
the app folder.

Creating Templates : After creating apps and their models, create


templates for each app.

1. Create a folder templates inside BASIC DIRECTORY (outer project


name folder)
2. Stores desired html files inside templates folder.

3. Next , Add the name of templates folder in the DIRS settings


under TEMPLATES of setting.py file of your project (inner project
name folder)

Creating views : Next, create views. Views receive the request in the
form of URL and provide response in form of templates.

Go inside products app  views.py and define view function :


Go inside inner project folder online_shop  urls.py file and edit:

You might also like