fixes in Django Middleware to not transform when not applicable, cleaned up settings