You are on page 1of 24

SEMINAR ON DJANGO

TITLE

Affiliation Arya
Authorized by Presented by
College of
Aman Mishra Aman Mishra
engineering and IT
INTRODUCTION TO DJANGO

• Django is a Python-based web framework which allows you to quickly create web
application without all of the installation or dependency problems that you normally
will find with other frameworks. Django uses MVT design pattern.
• The MVT stands for Model View Template.
• • It is a software design pattern.
• • It is a collection of three important components Model, View and Template.
• • Model helps to handle database.
• • The Template is a presentation layer which handles user interface part.(jinja 2 engine
is used).
• • The view is used to execute business logic and interact with a model to carry data
and renders a template(HTML , CSS is used).
 When you’re building a website, you always need a similar set of components: a way
to handle user authentication (signing up, signing in, signing out), a management panel
for your website, forms, a way to upload files, etc. Django gives you ready-made
components to use.
TEMPLATE

 Django provides a convenient way to generate dynamic HTML pages by using its
template system •
 A template consists of static parts of the desired HTML output as well as some
special syntax describing how dynamic content will be inserted
 • Django template engine is used to separate the design from the python code and
allows us to build dynamic pages.
 templates are HTML files.
VIEWS
A view function, or view is simply a Python function that takes a Web
request and returns a Web response. This response can be the HTML
contents of a Web page, or a redirect, or a 404 error, or an XML
document, or an image or anything, really. The view itself contains
whatever arbitrary logic is necessary to return that response.
The business logic is put in a file called views.py, placed in your
project or application directory.
There are two type of views in Django:-
 Function based views
 Class based views
MODEL

 • Model is a python class to represent database table


 • Model class is defined to create and manage database table
 • Once you define a Model Class then you need to perform two important steps
 • Makemigrations (Making SQL code with the help of model class)
 • Migrate (Execute SQL code to create table in the database)
Database Introduction

• Database is a place where all your application related data is stored


• This is our business data.
• Some database management system is required to manage database like oracle, mysql,
sqlite etc.
• Django provides inbuilt support for SQLite database
• The job of database management system like SQLite, is to manage database for your
application. It involves various operations like storing, retrieving, deleting, updating data.
• Logically database can be viewed as a collection of tables.
SQLite database
• SQLite is a C-language library that implements a small, fast, self-contained, highreliability, full-
featured, SQL database engine. SQLite is the most used database engine in the world. SQLite
is built into all mobile phones and most computers and comes bundled inside countless other
applications that people use every day.
• The SQLite file format is stable, cross-platform, and backwards compatible and the
developers pledge to keep it that way through at least the year 2050.
• SQLite source code is in the public-domain and is free to everyone to use for any purpose.

Default DBMS with Django


• Already configured database software is SQLite.
• In addition to SQLite, Django officially supports three other popular relational databases
that includes PostgreSQL , MySQL and Oracle. And unofficially, with third party packages,
Django supports connectivity to other relational databases that include: SAP (Sybase) SQL
Anywhere, IBM DB2, Firebird, etc
• To use different database software, you need to configure it in settings.py
RELATED WORK(WHY DJANGO IS USED)

 It’s very easy to switch database in Django framework.


 It has built-in admin interface which makes easy to work with it.
 Django is fully functional framework that requires nothing else.
 It has thousands of additional packages available.
 It is very scalable.
Versatility of Django
Django can build almost any type of website. It can also work with any client-side
framework and can deliver content in any format such as HTML, JSON, XML etc. Some
sites which can be built using Django are wikis, social networks, new sites etc.
Security
Since Django framework is made for making web development easy, it has been
engineered in such a way that it automatically do the right things to protect the website.
For example, In the Django framework instead of putting a password in cookies, the
hashed password is stored in it so that it can’t be fetched easily by hackers.
Portability
All the codes of the Django framework are written in Python, which runs on many
platforms. Which leads to run Django too in many platforms such as Linux, Windows and
Mac OS.
Popularity
Django is used in many popular sites like as: Disqus, Instagram, Knight Foundation,
MacArthur Foundation, Mozilla, National Geographic etc. There are more than 5k online
sites based on the Django framework. ( Source )
Sites like Hot Frameworks assess the popularity of a framework by counting the number
of GitHub projects and StackOverflow questions for each platform, here Django is in
6th position.
Project Structure- There will be following files-

manage.py-This file is used to interact with your project via command line(start the
server, sync the database etc).
folder –This folder contains all the packages of your project. Initially it contains four files –
1. _init_.py – It is python package.
2. settings.py – As the name indicates it contains all the website settings. In this file we
register any applications we create, the location of our static files, database configuration
details, etc.
3. urls.py – In this file we store all links of the project and functions to call.
4. wsgi.py – It is stands for web server gateway interface,This file is used in deploying the
project in WSGI. It is used to help your Django application communicate with the web
server.
Django Client-Server Architecture

• Client sends request by writing url on the browser. Sometimes optional data can also be
sent with the request. Such request is known as Http Request.
• When Django receives client’s request it first job is to find action to be taken against
requested url. Urls.py is the file where url patterns are mapped with the actions. These
actions are usually python functions. These python functions are defined in views.py file of
some app of your project.
• Django then invokes the found action (python function from views.py).
• This view function performs the business logic. Sometimes, it requests data access which
is either stored in the database or to be stored in the database. Model concept provides an
ease to the programmer to access database without bothering SQL commands.
• Model provides a python way to interact with the database.
• At last python function uses templates to return the final response.
• View returns the response to Django and Django send it to the browser which is known
as http response.
Create views
FUTURE SCOPE OF DJANGO

 Python
 Python is a renowned programming language that has been in the
industry for more than 25 years. Since its inception, it has gone many
updates and improvisations. Hence, Python is one of the fastest growing
programming languages in the world.
 What is the main reason why python is on the top? – Because of its
regular improvisation and easy to use language in the world.
• Django is a powerful open source framework that was
released initially in 2005. Factors such as simplicity, reliability, and
scalability have primarily contributed to its growth over the past
years. For these reasons, it has evolved to be one of the go-to
options for developers and businesses worldwide.

• It is a crowd and time tested, highly community supportive,


scalability, enough access to Django packages, advocates best
SEO practices.

You might also like