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.
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.
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.
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.
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.
There is this diagram from The Django Book (online version):
A breakdown of this process is described in Chapter 3 under the heading How Django Processes a Request: Complete Details.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With