mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 04:24:00 +03:00
made the BaseResource more interface-y (no implemented method) + added 'queryset' parameter for ModelListView
This commit is contained in:
parent
89e1cae28e
commit
42cda616da
|
@ -7,7 +7,7 @@ from djangorestframework.response import ErrorResponse
|
|||
from djangorestframework.serializer import Serializer, _SkipField
|
||||
|
||||
|
||||
class BaseResource(Serializer):
|
||||
class BaseResource(object):
|
||||
"""
|
||||
Base class for all Resource classes, which simply defines the interface
|
||||
they provide.
|
||||
|
@ -31,7 +31,7 @@ class BaseResource(Serializer):
|
|||
Typically raises a :exc:`response.ErrorResponse` with status code 400
|
||||
(Bad Request) on failure.
|
||||
"""
|
||||
return data
|
||||
raise NotImplementedError()
|
||||
|
||||
def retrieve(self, *args, **kwargs):
|
||||
raise NotImplementedError()
|
||||
|
@ -52,7 +52,7 @@ class BaseResource(Serializer):
|
|||
return not self.instance is None
|
||||
|
||||
|
||||
class Resource(BaseResource):
|
||||
class Resource(Serializer, BaseResource):
|
||||
"""
|
||||
A Resource determines how a python object maps to some serializable data.
|
||||
Objects that a resource can act on include plain Python object instances,
|
||||
|
@ -74,6 +74,9 @@ class Resource(BaseResource):
|
|||
# you should explicitly set the fields attribute on your class.
|
||||
fields = None
|
||||
|
||||
def deserialize(self, data, files=None):
|
||||
return data
|
||||
|
||||
|
||||
class FormResource(Resource):
|
||||
"""
|
||||
|
|
|
@ -201,10 +201,11 @@ class ListModelView(ListResourceMixin, ModelView):
|
|||
A view which provides default operations for list, against a model in the
|
||||
database.
|
||||
"""
|
||||
queryset = None
|
||||
_suffix = 'List'
|
||||
|
||||
|
||||
class ListOrCreateModelView(PostResourceMixin, ListResourceMixin, ModelView):
|
||||
class ListOrCreateModelView(PostResourceMixin, ListModelView, ModelView):
|
||||
"""
|
||||
A view which provides default operations for list and create, against a
|
||||
model in the database.
|
||||
|
|
Loading…
Reference in New Issue
Block a user