Life Cycle of Django

Life Cycle of Django

Request - Response life cycle in Django

 Thebasic principle of http protocol is the client sends a request to the server based on the request data, and the server sends a response to the client. We need a webserver and WSGI server while setting up the Django application .Webserver helps us serving static files &content. If it is not served by the web server static files, then it has to served by the WSGI server, which results in more num of request to the server. So gradually slow down the application performance web server balance request load on the server. So highly recommended using the webserver. 

A client can be known as a piece of software that can send a request by following the HTTPS/HTTP. In general terms, it is considered a web browser. We are using one of the variations of "Nginx, uWSGI and Django" or "Nginx, gunicorn and Django" or "Apache, mod wsgi and Nginx" when deploying the Django framework on the database.

When a request is sent by a client to the 0server that is forwarded to the webserver for the first time, it includes the rules of configuration to forward the request to the WSGI server or to handle it on its own.

Layers in Django Application

There are six layers in Django application

1-Request Middlewares

2-URL Dispatcher(URL Router)

3-Context Processors

4-Views

5-Template Renderers

6-Response Middlewares

The Application middlewares must manage the application when it comes in. Several middlewares we can have. This can be found in the project (settings.py). As handling the application, Django requests middlewares follows the command. Suppose we have middleware requests in order A, B, C, then the request is handled first by middleware A and then B, and then C.Django has a range of generic middlewares. We can also write middlewares of our own or tradition. It will be sent to the URL Router or URL dispatcher after the request handled by the middlewares.

URL Router takes the request from the middleware client, and from the request, it takes the URL Route. The URL router will attempt to match the request path to the available URL patterns based on the URL pathThese patterns of URLs are regular expressions. The request will be submitted to the View associated with the URL after matching the URL path with available URL patterns.

We are now in the Views business logic layer.Views use request and request data (data sent in GET, POST, etc.) to process the business logic.Using the request context processors, after processing the request in the view, it adds the context information that will help Template Renderers make the template to generate the HTTP response

Again, the application must return to the middleware of the Response for processing. Answer middlewares process the request, and before sending it back to the client(Browser), add or change the header/body information. After loading and showing the app to the end-user.

Application Life Cycle

A plan is a total of a large number of applications. That application has a purpose and can be reused for another task, such as the contact form on a website can be an application and can be reused for others. 

Create an Application

We assume we are in the project folder. In our main “myproject1” folder, the same folder then manage.py –

$ python manage.py startapp myapp

We just created myappl application, and like a project, Django creates a “myappl” folder with the application structure

myappl/

   __init__.py
    admin.py
    models.py 
    tests.py
    views.py 

Life Cycle of Django


Related Topics

Django Image Upload

Django is a python based web framework that uses Model View Template as its architecture. Django provides really quick web development with its functionalities. While we are building a website,...

3 minutes read.

Django Installation

Django Installation Django development environment consists of installing and setting up Python, Django, and a Database System since Django deals with a web application. Below the statement will guide you through installing Python 3.8.0 and...

2 minutes read.

Django CSRF

Django is a high-level python based web framework. Django is open source and free to use for all. Django provides many features to web developers like scalability, security, rapid development,...

4 minutes read.

Django Create App

Django is a Python-based web framework that is based on the Model View Template architecture. In this post, we will go through the installation and setup for our first Django...

4 minutes read.

Uses of Django

Django is a free and open-source Python-based web framework, which offers great functionalities to its users. Django was developed in 2003, and the final version was released in 2008 by...

3 minutes read.

Life Cycle of Django

Life Cycle of Django Request - Response life cycle in Django  Thebasic principle of http protocol is the client sends a request to the server based on the request data, and the server sends...

3 minutes read.

Django Project

Django Project Let's start to use it. Each web app you want to build in Django is called a project; and a project is a collection of apps. A software is a series of...

3 minutes read.

Django Environment Setup

Django is a free and open-source web framework, which uses Python as its programming language. It is based on Model View Template (MVT) architecture. A framework is a collection of...

4 minutes read.

How to Implement Multiple User Types with Django

Django Framework: Django is a framework that can make web applications more accessible and faster. Django is an open-source collection of python libraries, and Django can be used for both the...

3 minutes read.

Django Messages

Django Framework Django is a framework that can make web applications more accessible and faster. Django is an open-source collection of python libraries, and Django can be used for both the...

6 minutes read.

Django MVT

 MVT(Model View Template) MVT means Model View Template is a software design pattern The View is used to implement the business logic and to communicate with a model for data transmission and to...

2 minutes read.

How to create an app in Django

Create an application in Django Django is famous for its unique and fully managed application structure. For each functionality, an application can be created as a completely independent module. This article will take...

2 minutes read.

Django and React

This article will discuss the overview of Django and React, their advantages, applications, and most importantly, how to implement react in Django. What is Django? Django is a free and open-source web...

6 minutes read.

Features of Django

Features of Django Offers High Security:- Django is super secure. To prove the feature, we can always take examples of lots of websites which are present worldwide and possess huge traffic. Django is secure because it covers the...

3 minutes read.

Django Template System

Django Template System Django allows Python and HTML to be divided, the Python goes into views, and HTML goes into templates. Django relies on the render feature and the language of the Django Model...

5 minutes read.

Django Admin

To manage the content of the website, e.g., adding and deleting posts, web developers need an admin portal on the website. The admin portal allows trusted users, also knows as...

3 minutes read.

Django Model Fields

In Django, if we want to store the information about anything, we use Models. It contains various fields about the data. Generally, each model represents a database where all the...

4 minutes read.

Django Authentication

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 minutes read.

Django Create Project

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 minutes read.

Django REST Framework

Django REST Framework (DRF)is an open-source, powerful, and flexible toolkit used to build RESTful web APIs. It is built upon the Django framework. DRF increases the development speed. Django and...

4 minutes read.