Hello,
on 3.4.7 with this code:
urlpatterns = [
url(r'^$', FooViewSet.as_view({'post': 'create'}), name='foo-post'),
url(r'^/(?P<foo_pk>\d+)$', FooViewSet.as_view({'get': 'get'}),
name='foo-get'),
]
class ClasseViewSet(viewsets.ViewSet):
def create(self, request):
pass
def get(self, request, foo_pk):
pass
When i do a GET request to / the 'get' method is called:
File
"/venv/local/lib/python2.7/site-packages/rest_framework/viewsets.py", line
87, in view
return self.dispatch(request, *args, **kwargs)
File "/venv/local/lib/python2.7/site-packages/rest_framework/views.py",
line 474, in dispatch
response = self.handle_exception(exc)
File "/venv/local/lib/python2.7/site-packages/rest_framework/views.py",
line 434, in handle_exception
self.raise_uncaught_exception(exc)
File "/venv/local/lib/python2.7/site-packages/rest_framework/views.py",
line 471, in dispatch
response = handler(request, *args, **kwargs)
TypeError: get() takes exactly 3 arguments (2 given)
Which is not what i want :) I'd like to get a 405 because i want only POST
to be handled on that url pattern.
Is there a way I can use a ViewSet and have control over the methods a
pattern accepts?
thanks in advance,
Riccardo
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.