Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diagrams/Explanations of Django request processing?

Tags:

django

Is there a detailed diagram that describes how Django processes requests, from when the request is first handed to it until it hands back a response, specifically including how database connections are related to requests, e.g., 1 to 1, 1 to N, etc.?

If not, I'd appreciate a pointer to the point in the code where Django starts processing the request.

Thanks.

like image 215
Hank Gay Avatar asked Dec 02 '09 23:12

Hank Gay


People also ask

How does Django processes a request?

Django uses request and response objects to pass state through the system. When a page is requested, Django creates an HttpRequest object that contains metadata about the request. Then Django loads the appropriate view, passing the HttpRequest as the first argument to the view function.

Can you describe or outline the request response cycle?

The information sent or received is given the name of request and response. Request Objects contain the request made by the client. The server responds with the appropriate information according to Request Object. On the other hand, the Response Object is information served by the server to the client.

What is the typical order of an HTTP request response cycle in Django?

Django request middlewares follows the order while processing the request. Suppose if we have request middlewares in the order A, B, C then the request first processed by the middleware A and then B and then C. Django comes up with bunch of default middlewares. We can also write our own or custom middlewares.

What is request in Python Django?

django-request is a statistics module for django. It stores requests in a database for admins to see, it can also be used to get statistics on who is online etc.


2 Answers

There is this diagram from The Django Book (online version): alt text

A breakdown of this process is described in Chapter 3 under the heading How Django Processes a Request: Complete Details.

like image 181
jathanism Avatar answered Oct 21 '22 14:10

jathanism


I think this article includes the information you're looking for with a decent (if cluttered) diagram: http://uswaretech.com/blog/2009/06/django-request-response-processing/

You can also use the django-debug-toolbar to get more info about the SQL (and lots of other stuff) happening on behind the scenes of a particular request.

like image 27
John Debs Avatar answered Oct 21 '22 15:10

John Debs