Explain Django’s Request/Response Cycle.

Last updated 3 weeks, 1 day ago | 19 views 75     5

Tags:- Django

Django | Request/Response Cycle

Whenever a request is received by the Django server. The Request is processed by various middlewares and is passed to the URL Router. Then, the server looks for a matching URL in the urlpatterns defined for the project. If no matching URL is found, then a response with 404 Page Not Found status code is returned. If a URL matches,  then the corresponding code in the view file associated with the URL is executed to build and send a response.

The response is given in the form of HttpResponse. The response is not limited to that. The Response can be PDF, JSON, or CSV. It provides built-in support to provide responses of various types.