Skip to content

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

Merged
lovelydinosaur merged 3 commits intoencode:masterfrom
BrickXu:fix_2171
Dec 3, 2014
Merged

Not allow to pass an empty actions to viewset.as_view()#2175
lovelydinosaur merged 3 commits intoencode:masterfrom
BrickXu:fix_2171

Conversation

@BrickXu
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

BrickXu commented Dec 2, 2014

Also add unittest for viewset.as_view()

Comment thread tests/test_viewsets.py Outdated
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK.

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

Thanks!

@gitaarik
Copy link
Copy Markdown

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
Copy Markdown
Contributor

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

@gitaarik
Copy link
Copy Markdown

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