Non-global middleware in Django

前端 未结 8 1000
生来不讨喜
生来不讨喜 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:35

    The best thing I've been able to find is using if request.path_info.startswith('...') to skip over the middleware by just returning the request. Now, you could create middleware just for the sake of skipping and then inherit that. Maybe you could do something even simpler and save that list in your settings.py and then skip all those. If I'm wrong in any way, let me know.

提交回复
热议问题