mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 20:27:12 +03:00
17 lines
654 B
Python
17 lines
654 B
Python
from djangorestframework.modelresource import InstanceModelResource, ListOrCreateModelResource
|
|
from modelresourceexample.models import MyModel
|
|
|
|
FIELDS = ('foo', 'bar', 'baz', 'absolute_url')
|
|
|
|
class MyModelRootResource(ListOrCreateModelResource):
|
|
"""A create/list resource for MyModel.
|
|
Available for both authenticated and anonymous access for the purposes of the sandbox."""
|
|
model = MyModel
|
|
fields = FIELDS
|
|
|
|
class MyModelResource(InstanceModelResource):
|
|
"""A read/update/delete resource for MyModel.
|
|
Available for both authenticated and anonymous access for the purposes of the sandbox."""
|
|
model = MyModel
|
|
fields = FIELDS
|