How do you determine at startup time if a piece of middleware should be used?
Write code to remove the middleware from the settings in [app]/init.py.
List the middleware beneath an entry of django.middleware.IgnoredMiddleware.
Implement the not_used method in your middleware class.
Raise MiddlewareNotUsed in the init function of your middleware.