Based on my current understanding of Django, this is how a user request is responded to.
- User requests a page
- Request reaches Request Middlewares, which could manipulate or answer the request
- The URLConffinds the related View using urls.py
- View Middlewares are called, which could manipulate or answer the request
- The view function is invoked
- The view could optionally access data through models
- All model-to-DB interactions are done via a manager
- Views could use a special context if needed
- The context is passed to the Template for rendering
- Template uses Filters and Tags to render the output
- Output is returned to the view
- HTTPResponse is sent to the Response Middlerwares
- Any of the response middlewares can enrich the response or return a completely new response
- The response is sent to the user’s browser.
Please leave a comment if I have got something wrong.
4 replies on “Django Flowchart”
This is a nice overview. You should consider creating a ticket to include it in the default django documentation.
[…] python code and libraries that facilitate the creation of your application. There are a few complex diagrams of Django functionality on the web but here is a simplified version that shows the relationship between the key […]
In step #9 in the diagram shouldn’t the arrow be between Template-View instead of Template-Model?
Step #8, #9 and #b are slightly mixed up. Will need to revise the diagram.