django-rest-framework/examples/modelresourceexample/resources.py

15 lines
458 B
Python
Raw Normal View History

2011-06-15 17:09:57 +04:00
from djangorestframework.resources import ModelResource
2012-02-23 13:21:01 +04:00
from djangorestframework.reverse import reverse
2011-06-15 17:09:57 +04:00
from modelresourceexample.models import MyModel
2011-06-15 17:09:57 +04:00
class MyModelResource(ModelResource):
model = MyModel
fields = ('foo', 'bar', 'baz', 'url')
ordering = ('created',)
2012-02-23 13:21:01 +04:00
def url(self, instance):
return reverse('model-resource-instance',
kwargs={'id': instance.id},
request=self.request)