Fixed #5228 Set ViewSet args/kwargs/request before dispatch #5229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes issue #5228
Actually I didn't find when
args
,kwargs
andrequest
are set in the dispatch and just set them before that as Django does.P.S.
I found where "the magic happens". If we want restframework's request to be available as early as possible (before
dispatch
as is with Django's request object), even on normal API views then setting of djangorestframework's request can be done inas_view
method (but should be done twice - once forAPIView
and once forViewSet
).Even If we decided that it's not a problem django's request object to be available before
dispatch
(as is right now for APIView) because RestFramework supports Django 1.8+ we can remove setting ofargs
andkwargs
in dispatch, because they are already set byas_view
decorator.I can update the PR with these changes if you want?