aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blogpost/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/blogpost/views.py')
-rw-r--r--examples/blogpost/views.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/blogpost/views.py b/examples/blogpost/views.py
index e47f4a5b..c4b54f73 100644
--- a/examples/blogpost/views.py
+++ b/examples/blogpost/views.py
@@ -1,12 +1,11 @@
-from djangorestframework.modelresource import InstanceModelResource, RootModelResource
+from djangorestframework.modelresource import InstanceModelResource, ListOrCreateModelResource
from blogpost import models
BLOG_POST_FIELDS = ('created', 'title', 'slug', 'content', 'absolute_url', 'comment_url', 'comments_url')
COMMENT_FIELDS = ('username', 'comment', 'created', 'rating', 'absolute_url', 'blogpost_url')
-MAX_POSTS = 10
-class BlogPosts(RootModelResource):
+class BlogPosts(ListOrCreateModelResource):
"""A resource with which lists all existing blog posts and creates new blog posts."""
model = models.BlogPost
fields = BLOG_POST_FIELDS
@@ -16,7 +15,7 @@ class BlogPostInstance(InstanceModelResource):
model = models.BlogPost
fields = BLOG_POST_FIELDS
-class Comments(RootModelResource):
+class Comments(ListOrCreateModelResource):
"""A resource which lists all existing comments for a given blog post, and creates new blog comments for a given blog post."""
model = models.Comment
fields = COMMENT_FIELDS