diff options
| author | Tom Christie | 2013-04-26 14:59:21 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-04-26 14:59:21 +0100 |
| commit | 8fa79a7fd38dda015afa658084361c6da2856e46 (patch) | |
| tree | ef8080a9d24b488402429c0bae101e3f395f1f8b /rest_framework/viewsets.py | |
| parent | e301e2d974649a932ab9a7ca32199c068fa30495 (diff) | |
| download | django-rest-framework-8fa79a7fd38dda015afa658084361c6da2856e46.tar.bz2 | |
Deal with List/Instance suffixes for viewsets
Diffstat (limited to 'rest_framework/viewsets.py')
| -rw-r--r-- | rest_framework/viewsets.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 9133fd44..bd25df77 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -35,12 +35,16 @@ class ViewSetMixin(object): """ @classonlymethod - def as_view(cls, actions=None, name_suffix=None, **initkwargs): + def as_view(cls, actions=None, **initkwargs): """ Because of the way class based views create a closure around the instantiated view, we need to totally reimplement `.as_view`, and slightly modify the view function that is created and returned. """ + # The suffix initkwarg is reserved for identifing the viewset type + # eg. 'List' or 'Instance'. + cls.suffix = None + # sanitize keyword arguments for key in initkwargs: if key in cls.http_method_names: @@ -74,7 +78,11 @@ class ViewSetMixin(object): # like csrf_exempt from dispatch update_wrapper(view, cls.dispatch, assigned=()) + # We need to set these on the view function, so that breadcrumb + # generation can pick out these bits of information from a + # resolved URL. view.cls = cls + view.suffix = initkwargs.get('suffix', None) return view |
