aboutsummaryrefslogtreecommitdiffstats
path: root/examples/modelresourceexample/views.py
blob: 5495a2931395964c93db040e7ecbb85fb3557cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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