Closed JavierGonza closed 6 years ago
Hello @JavierGonza and thank you very much for your contribution.
I understand that you want to extend the compability with the supported django versions, which is always welcome. Though I look at the django documentation and see that the class (inheriting from object) is already the current 1.11 approach.
see: https://docs.djangoproject.com/en/1.11/topics/http/middleware/#writing-your-own-middleware
Could you give more details in what problems you ran and what django version you are using?
If u try to use your middleware in settings.MIDDLEWARE you get an error like this: ... self.load_middleware() mw_instance = middleware(handler) TypeError: object() takes no parameters That happends in django>=1.10 and because your class is like old-style and try to run with new-style settings
Your middleware is written in old-style middleware and we need to adapt it to new-style if we want to use it with settings.MIDDLEWARE( new style) instead of settings.MIDDLEWARE_CLASSES (old style). That happens in django >=1.10, with this patch, we can use your custom middleware in both settings. see:
Ah now I see, you are right, that did not work. Please check out https://github.com/PaesslerAG/django-currentuser/pull/7 where I avoided using MiddlewareMixin.
Now you can use old and style middleware in django >=1.10, use settings.MIDDLEWARE or settings.MIDDLEWARE_CLASSES