From 53f52765fc90472a05cbeb34760b45f735a7332c Mon Sep 17 00:00:00 2001 From: BrickXu Date: Tue, 2 Dec 2014 12:55:34 +0800 Subject: Not allow to pass an empty actions to viewset.as_view(). Refs issue #2171 --- rest_framework/viewsets.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rest_framework/viewsets.py') diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 84b4bd8d..70d14695 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -48,6 +48,12 @@ class ViewSetMixin(object): # eg. 'List' or 'Instance'. cls.suffix = None + # actions must not be empty + if not actions: + raise TypeError("The `actions` argument must be provided when " + "calling `.as_view()` on a ViewSet. For example " + "`.as_view({'get': 'list'})`") + # sanitize keyword arguments for key in initkwargs: if key in cls.http_method_names: -- cgit v1.2.3