Questions tagged «django-middleware»

3
如何在Django中设置自定义中间件
我正在尝试创建中间件,以有选择地将kwarg传递给满足条件的每个视图。 问题是我找不到如何设置中间件的示例。我已经看到了覆盖我想要的方法的类process_view: Class CheckConditionMiddleware(object): def process_view(self, request): return None 但是我该把课程放在哪里?我是否要创建一个中间件应用程序并将其放入其中,然后在其中引用它settings.middleware?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.