Django Book 翻译
菜单>:
TOC
返回
原文:
The order is significant. On the request and view phases, Django applies middleware in the order given in ``MIDDLEWARE_CLASSES`` , and on the response and exception phases, Django applies middleware in reverse order. That is, Django treats ``MIDDLEWARE_CLASSES`` as a sort of wrapper around the view function: on the request it walks down the list to the view, and on the response it walks back up. See the section How Django Processes a Request: Complete Details in Chapter 3 for a review of the phases.
翻译:
这里中间件出现的顺序非常重要。在request和view的处理阶段,Django按照 ``MIDDLEWARE_CLASSES`` 中出现的顺序来应用中间件,而在response和异常处理阶段,Django则按逆序来调用它们。也就是说,Django将 ``MIDDLEWARE_CLASSES`` 视为view函数外层的顺序包装子:在request阶段按顺序从上到下穿过,而在response则反过来。关于Django处理阶段的详细信息,请参见第三章"Django怎么处理一个请求: 完整细节"这一节。
备注:
译者: