From 412b5fc2d54def2f2601b860b80afaa52d595e58 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 14 Jun 2011 18:22:13 +0100 Subject: Support for nesting resources etc... --HG-- rename : djangorestframework/tests/resources.py => djangorestframework/tests/serializer.py --- examples/blogpost/urls.py | 14 ++++++++------ examples/modelresourceexample/urls.py | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'examples') diff --git a/examples/blogpost/urls.py b/examples/blogpost/urls.py index c677b8fa..6fde612e 100644 --- a/examples/blogpost/urls.py +++ b/examples/blogpost/urls.py @@ -11,9 +11,10 @@ class BlogPostResource(ModelResource): """ A Blog Post has a *title* and *content*, and can be associated with zero or more comments. """ - model = BlogPost - fields = ('created', 'title', 'slug', 'content', 'url', 'comments') - ordering = ('-created',) + class Meta: + model = BlogPost + fields = ('created', 'title', 'slug', 'content', 'url', 'comments') + ordering = ('-created',) def comments(self, instance): return reverse('comments', kwargs={'blogpost': instance.key}) @@ -23,9 +24,10 @@ class CommentResource(ModelResource): """ A Comment is associated with a given Blog Post and has a *username* and *comment*, and optionally a *rating*. """ - model = Comment - fields = ('username', 'comment', 'created', 'rating', 'url', 'blogpost') - ordering = ('-created',) + class Meta: + model = Comment + fields = ('username', 'comment', 'created', 'rating', 'url', 'blogpost') + ordering = ('-created',) urlpatterns = patterns('', diff --git a/examples/modelresourceexample/urls.py b/examples/modelresourceexample/urls.py index bb71ddd3..86960367 100644 --- a/examples/modelresourceexample/urls.py +++ b/examples/modelresourceexample/urls.py @@ -4,9 +4,10 @@ from djangorestframework.resources import ModelResource from modelresourceexample.models import MyModel class MyModelResource(ModelResource): - model = MyModel - fields = ('foo', 'bar', 'baz', 'url') - ordering = ('created',) + class Meta: + model = MyModel + fields = ('foo', 'bar', 'baz', 'url') + ordering = ('created',) urlpatterns = patterns('', url(r'^$', ListOrCreateModelView.as_view(resource=MyModelResource), name='model-resource-root'), -- cgit v1.2.3