[Fixed]-Django – application specific middleware

6👍

This is probably not possible in way that you want it, because django does not track what view comes from what application. But you can create some middleware with condition inside process_view, you can check here what view is being called and do something if view is matching your criteria (in that case, view comes from particular app).

Another approach, if you’re using class-based views is to create some view mixin or base view in your application, decorate it with your middleware and use it in each view from your application.

Leave a comment