aboutsummaryrefslogtreecommitdiffstats
path: root/examples/modelresourceexample/views.py
blob: e912c019df32c2a352f1077ddf7f79ee34cd677d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from djangorestframework.modelresource import ModelResource, RootModelResource
from modelresourceexample.models import MyModel

FIELDS = ('foo', 'bar', 'baz', 'absolute_url')

class MyModelRootResource(RootModelResource):
    """A create/list resource for MyModel.
    Available for both authenticated and anonymous access for the purposes of the sandbox."""
    model = MyModel
    allowed_methods = anon_allowed_methods = ('GET', 'POST')
    fields = FIELDS

class MyModelResource(ModelResource):
    """A read/update/delete resource for MyModel.
    Available for both authenticated and anonymous access for the purposes of the sandbox."""
    model = MyModel
    allowed_methods = anon_allowed_methods = ('GET', 'PUT', 'DELETE')
    fields = FIELDS