1π
I believe you should be able to override the initial()
method on your view in order to achieve what youβre attempting. The docstring from the APIView
class reads:
"""
Runs anything that needs to occur prior to calling the method handler.
"""
So, it would look something like:
class FaveoAPIView(APIView):
def initial(self, request, *args, **kwargs):
super(FaveoAPIView, self).initial(request, *args, **kwargs)
# Manipulate request.data to your heart's content here
In APIView
, this is called immediately before your method handler.
π€Joey Wilhelm
0π
super(FaveoAPIView, self).dispatch(request, *args, **kwargs)
will call initialize_request
turning the request into a DRF one. This can only be once therefore itβll fail after that.
Instead of fixing a broken solution, could you rather tell us about your actual issue, i.e. why you need to access the requests data before the view itself is called ?
π€Linovia
Source:stackexchange.com