diff options
| author | Tom Christie | 2011-05-23 17:07:31 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-23 17:07:31 +0100 |
| commit | c53175914752502629141556f3e001e9d2e9f7fa (patch) | |
| tree | d68bc4f0b2baeed2a90d6d20295423583603ba2b /djangorestframework/views.py | |
| parent | e7f8c06dbbbc9e4ae91327ee02cd8147777b17e2 (diff) | |
| download | django-rest-framework-c53175914752502629141556f3e001e9d2e9f7fa.tar.bz2 | |
name and description
Diffstat (limited to 'djangorestframework/views.py')
| -rw-r--r-- | djangorestframework/views.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/djangorestframework/views.py b/djangorestframework/views.py index 81567e68..a0471166 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -51,6 +51,18 @@ class BaseView(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, View): name = None description = None + @classmethod + def as_view(cls, **initkwargs): + """ + Override the default :meth:`as_view` to store an instance of the view + as an attribute on the callable function. This allows us to discover + information about the view when we do URL reverse lookups. + """ + view = super(BaseView, cls).as_view(**initkwargs) + view.cls_instance = cls(**initkwargs) + return view + + @property def allowed_methods(self): """ @@ -122,12 +134,12 @@ class ModelView(BaseView): class InstanceModelView(InstanceMixin, ReadModelMixin, UpdateModelMixin, DeleteModelMixin, ModelView): """A view which provides default operations for read/update/delete against a model instance.""" - pass + _suffix = 'Instance' class ListModelView(ListModelMixin, ModelView): - """A view which provides default operations for list, against a model in the database.""" - pass + """A view which provides default operations for list, against a model in the database.""" + _suffix = 'List' class ListOrCreateModelView(ListModelMixin, CreateModelMixin, ModelView): - """A view which provides default operations for list and create, against a model in the database.""" - pass + """A view which provides default operations for list and create, against a model in the database.""" + _suffix = 'List' |
