2011-01-30 21:30:39 +03:00
|
|
|
from django.conf.urls.defaults import patterns, url
|
2011-05-16 17:11:36 +04:00
|
|
|
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
|
|
|
|
from djangorestframework.resources import ModelResource
|
|
|
|
from modelresourceexample.models import MyModel
|
|
|
|
|
|
|
|
class MyModelResource(ModelResource):
|
|
|
|
model = MyModel
|
|
|
|
fields = ('foo', 'bar', 'baz', 'url')
|
|
|
|
ordering = ('created',)
|
2011-01-30 21:30:39 +03:00
|
|
|
|
2011-05-19 11:36:55 +04:00
|
|
|
urlpatterns = patterns('',
|
2011-05-16 17:11:36 +04:00
|
|
|
url(r'^$', ListOrCreateModelView.as_view(resource=MyModelResource), name='model-resource-root'),
|
|
|
|
url(r'^([0-9]+)/$', InstanceModelView.as_view(resource=MyModelResource)),
|
2011-01-30 21:30:39 +03:00
|
|
|
)
|