Web Framework
Web Framework
Introduction
● Django is a back-end server side web framework.
● It is free, open source and written in Python.
● It makes it easier to build web pages using Python.
● It is especially helpful for database driven websites.
MVT Pattern- How does Django works?
MVT (Model-View-Template) determines the total structure and
workflow of a Django application. In an MVT architecture —
● The Model manages the data and is represented by a database. A
model is basically a database table.
● The View receives HTTP requests and sends HTTP responses. A
view interacts with a model and template to complete a response.
● The Template is basically the front-end layer and the dynamic
HTML component of a Django application.
Django MVT Pattern
Features
○ Rapid Development
○ Secure
○ Scalable
○ Fully loaded
○ Versatile
○ Open Source
○ Vast and Supported Community
Installation Steps
Installation Steps
Steps for creating a CRUD app in Django
● Install Django & start a new project
● Create an App
● Create the Model
● Create the Admin Interface
● Create the View
● Define the URLs (i.e. URL to View mapping)
● Create the Templates
Installation Steps
Installation Steps
To stop the server press ctrl c and enter. Once server is stop it will not show you your project
Create Django project
To change the port we can use
runserver and port number
which you want to create ( if you
are doing multiple projects)
CRUD Operations
CRUD stands for Create, Read, Update & Delete. These are the four basic
operations which are executed on Database Models.
1. Read Operation
The ability of the application to read data from the database.
2. Create Operation
The ability of the application to store data in the database.
3. Update Operation
The ability of the application to edit the stored value in the database.
4. Delete Operation
The ability of the application to delete the value in the database.
Example:
Majority of applications on the internet are CRUD applications.
For example –
Facebook uses CRUD operations to save your data on their database.
You can change your profile picture that means perform the update
operation.
Of course, you can see the data in-app or browser which is read
operation.
Also, you can delete your Facebook account which is delete operation.
Summarising it, almost all the applications you use are CRUD
applications.
Implementation steps
Step 1: Django Project Setup
Step 3: Create View and URL’s for Listing, Create, Read, Update
and Delete Objects