When client sends a request(http synchronous) and waits for a response from the service, a lot happens in the server side, server will get the request and process it and return the response to the client.
When client made a request, it will be sent to the server like Nginx(in development, django will use the default development server), then it will connect to the wsgi(standard interface for communication between an application and the web server) module in django to talks to the django project
Then the request will be send through the middleware, django has its own premade middleware for things like authendication, session and many more. Middleware is like a gatekeeper, request has to cross each one in order and vice versa. you can even write your own custom middleware.
urls is the router in django, django will look for the requested url and calls the view
view in django where the logic will be written, view will get the requesting data and process it, queries the model and return back the HttpResponse as template or any other format like json, xml. view is the place where you work, most of the time to build the logic for the application.
Templates in django are normal html files with extract features included, it will be send to client as html file pre rendered in the server. Template can be reused in another templates by including it (like reactjs component).
Response has to cross the Middleware in the reverse order, check Note 2. you can validate the response or do any kind of validation in the response middleware.
Top comments (0)