开发者

Django order of execution

开发者 https://www.devze.com 2023-03-09 22:07 出处:网络
In what order does django execute the various c开发者_如何学Pythonomponents when it receives a request? Specifically when does the middleware get invoked compared to the function that a route resolves

In what order does django execute the various c开发者_如何学Pythonomponents when it receives a request? Specifically when does the middleware get invoked compared to the function that a route resolves to? And when do context processors get called?

Thanks


The middlewares are executed before the view and when returning the response. The context processor is executed when rendering a template, usually at the end of the view.

So:

(request) -> middleware, from top to bottom -> view -> context_processor -> (response) -> middleware, from bottom to top

0

精彩评论

暂无评论...
验证码 换一张
取 消