Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not allow to pass an empty actions to viewset.as_view() #2175

Merged
merged 3 commits into from
Dec 3, 2014

Conversation

BrickXu
Copy link
Contributor

@BrickXu BrickXu commented Dec 2, 2014

Validate actions value when invoke as_view(), raise a TypeError if no actions was passed in.

Refs #2171

@BrickXu
Copy link
Contributor Author

BrickXu commented Dec 2, 2014

Also add unittest for viewset.as_view()


class BasicViewSet(GenericViewSet):
def list(self, request, *args, **kwargs):
return Response({'METHOD': 'LIST'})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

METHOD is a confusing string to use here, as it could mean the request method. ACTION would be more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

tomchristie added a commit that referenced this pull request Dec 3, 2014
Not allow to pass an empty actions to viewset.as_view()
@tomchristie tomchristie merged commit c5a2d50 into encode:master Dec 3, 2014
@tomchristie
Copy link
Member

Thanks!

@gitaarik
Copy link

Not sure, but I was following the documentation about testing and got this exception

The actions argument must be provided when calling .as_view() on a ViewSet. For example .as_view({'get': 'list'})

So, should the documentation be updated to add this actions argument?

http://www.django-rest-framework.org/api-guide/testing/#forcing-authentication

@xordoquy
Copy link
Collaborator

AccountDetail isn't a viewset so it doesn't have any use of the actions

@gitaarik
Copy link

Ah yeah, of course, sometimes all the different kind of views are confusing ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants