0% found this document useful (0 votes)
16 views

10-22-2024

The document outlines the structure of a Django project, detailing key modules such as __init__.py, asgi.py, settings.py, urls.py, and wsgi.py, each serving specific purposes like package initialization and server configuration. It also explains the components of the settings.py file, including application definitions, middleware, templates, and database configurations. Additionally, it introduces the MVT architectural design pattern, which divides a web application into Model, View, and Template components.

Uploaded by

shyamkrishna2702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

10-22-2024

The document outlines the structure of a Django project, detailing key modules such as __init__.py, asgi.py, settings.py, urls.py, and wsgi.py, each serving specific purposes like package initialization and server configuration. It also explains the components of the settings.py file, including application definitions, middleware, templates, and database configurations. Additionally, it introduces the MVT architectural design pattern, which divides a web application into Model, View, and Template components.

Uploaded by

shyamkrishna2702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Structure of django project

Project folder consist of the following modules


1. __init__.py
2. asgi.py
3. settings.py
4. urls.py
5. wsgi.py

__init__.py : it is called package initialize or it is module which


represents a folder as package. This module gets executed
automatically when package is imported.

asgi.py : This module is used to configure asgi server

settings.py : This is project configuration file or module


1. Application definitions
a. Installing applications within server
b. Django project comes with predefined applications

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]
2. Middleware
Configuration of middleware application, django provides
predefined middleware. Django developer can also develop user
defined middleware.

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

3. TEMPLATES
This is used for configuration of templates (HTML)
It is used to define location where templates are saved.

4. DATABASE
This variable is used for configuring DATABASE (OR) providing
database related information

Urls.py

URL stands for Uniform Resource Location or Locator


Urls.py is used for url mapping or defining url pattern
Mapping is nothing accessing resource with one name (url-
pattern).
Server side programs are private, to access these programs by
client each program is given public url(name), this name is given
inside urls.py

Wsgi.py
This module is used for configuration of wsgi container or
application.

Application is a collection of modules


1. App.py
2. Models.py
3. Views.py
4. Admin.py
5. Tests.py

Admin.py

Admin.py is used for registering models with admin interface or


application

Models.py
This is used for defining models.

Views.py
View.py is called controller
Views.py used for defining views for web application
The job controller is receiving and processing it and generating
output.
Views are used for controlling web application by communicating
models and templates.

What is MVT?
MVT stands for Model, View, Template
MVT is architectural design pattern. A design pattern defines set
of rules and regulations for organizing programs or code.

Every web application is django is divided into 3 parts


1. Model : Persistent Logic
2. View : Business Logic (input/output)
3. Template : Presentation Logic (Output/Input)

Persistent Logic : Database Logic


Presentation Logic: Templates (HTML)
Business Logic : Receives input and process it generate output
using templates
codewithsatishgupta : telegram

DJANGO with Rest API @ 9:00 AM IST by Mr Satish Gupta


Day-1 https://youtu.be/psSJkbDwkMk
Day-2 https://youtu.be/TzyRL0HZ-DM
Day-3 https://youtu.be/WXVbeVn8qUs
Day-4 https://youtu.be/gWyf1wa60o8

You might also like