문제

Does the Middleware framework hook the request object before it is sent to the urlconf?
Also, does this hook happen after it goes through WSGIHandler?
So, just in respect to these three "layers", is it the order in which request is processed?
WSGIHandler --> Middleware --> urlconf

도움이 되었습니까?

해결책

The WSGI handler is what coordinates all requests to your Python web application; technically, your WSGI handler is the code that calls the rest of the Django request/response process. So everything is "going through" your WSGI handler, if you are using one.

When a request comes in, Django will construct a request object and successively pass it to each piece of registered middleware. This request object is then passed to the view, which is expected to return a response object that may be serialized to a valid HTTP response. Since the url conf simply maps a pattern to a view function, it doesn't matter when it is matched; ultimately, the corresponding view is called after the middleware. So you may make assumptions in your view code that any registered middleware has already been executed.

Googling around produced this high level view of the process.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top