Fixed #5228 Set ViewSet args/kwargs/request before dispatch by vstoykov · Pull Request #5229 · encode/django-rest-framework (original) (raw)

This fixes issue #5228

Actually I didn't find when args, kwargs and request 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 in as_view method (but should be done twice - once for APIView and once for ViewSet).
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 of args and kwargs in dispatch, because they are already set by as_view decorator.

I can update the PR with these changes if you want?