You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
URLPathVersioning should maybe remove the version_param kwarg from subsequent view dispatch? #3718
I've been playing around with getting URLPathVersioning working properly, and have discovered what might be a bug, or maybe just undocumented (or obvious and expected) behaviour.
File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 463, in dispatch
response = handler(request, *args, **kwargs)
TypeError: post() got an unexpected keyword argument 'version'
Investigation shows that the ObtainAuthToken.post() method doesn't accept any kwargs, so it's clearly failing because it's getting version passed in by default from the rest of the versionating mechanism.
Simplest fix would be to just fix the definition of ObtainAuthToken.post(self, request, **kwargs),
but it made me wonder if it'll be an issue for other views that are receiving a somewhat unexpected kwarg, and which is by intent already available to them in request.version.
If there's no good reason to keep it around after extracting it, would it make sense to clean it from the
view args in views.APIView somewhere in the initial pre-dispatch phases, maybe as simple as a kwargs.pop(request.versioning_scheme.version_param, None) (with some checks around it) in the appropriate place?
I'm currently subclassing authtoken.ObtainAuthToken to do exactly this in post(), but I figured it might make sense to raise a a more general issue.
Activity
xordoquy commentedon Dec 10, 2015
I'd rather fix the AuthToken to accept the extra kwarg.
xordoquy commentedon Dec 10, 2015
Thanks for reporting.
lovelydinosaur commentedon Dec 10, 2015
Seems reasonable.
Add extra args/kwargs to authtoken's views (encode#3718)
Merge pull request #3723 from linovia/bug/authtoken_versionning_compat