Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

INT253

WEB DEVELOPMENT IN
PYTHON USING
.
DJANGO
Introduction
• Django is a high-level Python web framework that encourages rapid
development and clean, pragmatic design.
• It follows the Model-View-Controller (MVC) architectural pattern,
with slight variations, and it's known for its simplicity, flexibility, and
scalability.
MVC Architecture
• Framework is the architectural /design pattern that separates an
application into three main logical component Model,View and
Controller
• It provides a clear separation of business logic,UL logic and input
logic.
• It offers full control on the HTML and URL which make it easy design
web application architecture.
• It is a powerful URL mapping component
Components of MVC Architecture
.
Working of MVC Architecture
• Assume End user sends a request to server to get a
list of student studying in a class
• Server send request to particular
controller(handles student)
• Controller request the model handling students to
return a list of all student studing in a class
• Model query the database for list of students and
returning the list back to controller
• Response from model was successful,controller
ask for view associated with student to return a
presentation of list of students
• View take list of students from controller and
render the list into HTML that used by the browser
• Controller take presentation and return back to
user
Key components with Django
1. Models:
• Django models represent the data structure of the application, defining
the schema for the database tables.
• Models are defined as Python classes, and Django automatically
generates database tables based on these classes.
2. Views
• Views handle the logic of processing a user's request and returning an
appropriate response.
• Views can be simple functions or classes and are responsible for
processing data, interacting with models, and rendering templates.
3.Templates:

• Django uses templates to define the structure of HTML pages.


Templates allow you to dynamically generate HTML by embedding
variables, logic, and control structures within the template.
4.URLS and Routing
• The URL routing mechanism in Django maps URL to views.
• This is achieved through the urls.py file ,where defining patterns and
their corresponding views
• Django uses regular expressions to match URL patterns and direct
them to the appropriate views
5. Middleware

• Middleware is a way to process requests globally before they reach the


view or after the view has processed the request. Examples include
authentication middleware, security middleware, etc.
6. Forms

• Django provides a forms framework for handling user input. Forms


handle validation, processing, and rendering of HTML forms, making
it easier to manage user-submitted data.
7. Admin Interface

• Django comes with a built-in administrative interface that can be


easily customized to manage models and their data. This allows
developers and administrators to interact with the database without
writing custom views or templates.
8.Django ORM(Object-Relational
Mapping)

• Django includes a powerful and flexible ORM for interacting with


databases. It abstracts the database layer, allowing developers to work
with databases using Python code rather than SQL queries directly.
9.Security Features

• Django incorporates various security features, such as protection


against common web vulnerabilities like SQL injection, cross-site
scripting (XSS), and cross-site request forgery (CSRF).
10. Django Rest Framework (DRF):

• An extension to Django for building APIs. It makes it easy to build,


test, and debug APIs for web applications.
• Django is widely used for developing web applications and has a
strong and active community. It follows the "Don't Repeat Yourself"
(DRY) and "Convention Over Configuration" principles, which
contribute to its simplicity and productivity.

You might also like