Middleware support
- Instead of importing Mixin in every View, Do this job using middleware is more durable.
-
Sorry I was crating the pull request on my fork but instead created on Parent repo. So you can ignore This pull request.
-
However if you liked the idea , I can explain what I did and why ? and can write test cases too
@inforian Thanks for making a PR. If you can briefly explain how this betters the library I am all for it. Write somes tests would be great. Lastly, add some quick documentation on how it should be installed. Would this be a breaking change for current users? Or would does it compliment the mixin?
-
The main idea is to avoid redundancy of using
Mixinin everyviewset. Instead their must be a way where you have to mention just once and that will be applicable everywhere (Some configurable settings can be provided). -
So I decided to write a
Django middlewarefor the same which will use this mixin functions like :- In
process_request->initial -
process_exception->handle_exception -
process_response->finalize_response
- In
-
But during Implementation I faced some issues like : - Your
MixinuseDRF Request ObjectbutMiddlewarewill passHttpRequest object, So some things may not be accessible in Mixin likerequest.data.- In
finalize_responsesome response do not haverendered_content - calling super_class
super(BaseLoggingMixin, self).any_function(request, *args, **kwargs)
- In
-
However I fixed above issues but then I realize This repo aims at
DRFnotDjango, So a Middlware won't be a good option. But I still think there must be a single way of enabling thisloggingfunctionality instead of use Mixin in every Viewset. -
So I wanted to contribute and enable above functionality (keeping the old one too) but first I wanted to know your views and Any thoughts on what will be the best way to do so ?