Django urlmiddleware allows you to define middleware in your Django project with a URL based configuration, like views. This then allows you to enable middleware for specific paths rather than only globally for all requests.
See http://urlmiddleware.readthedocs.org/ for further documentation.