Non-global middleware in Django

前端 未结 8 973
生来不讨喜
生来不讨喜 2020-12-12 21:59

In Django there is a settings file that defines the middleware to be run on each request. This middleware setting is global. Is there a way to specify a set of middleware

相关标签:
8条回答
  • 2020-12-12 22:50

    Use django.core.urlresolvers.resolve() against request.path in a wrapper for the middleware to try to see if the view is within the app, and skip processing if so.

    0 讨论(0)
  • 2020-12-12 22:54

    You can use process_view method, that is called before calling the view func. In process_view you can check — if this view requires this middleware interception.

    0 讨论(0)
提交回复
热议问题