aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blogpost/views.py
diff options
context:
space:
mode:
authortom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
committertom christie tom@tomchristie.com2011-02-19 10:26:27 +0000
commit805aa03ec1871f6a766d9052b348ddce9e9843c3 (patch)
tree8ab5b6a7396236aa45bbc61e8404cc77fc75a9c5 /examples/blogpost/views.py
parentb749b950a1b4bede76b7e3900a6385779904902d (diff)
downloaddjango-rest-framework-805aa03ec1871f6a766d9052b348ddce9e9843c3.tar.bz2
Yowzers. Final big bunch of refactoring for 0.1 release. Now support Django 1.3's views, admin style api is all polished off, loads of tests, new test project for running the test. All sorts of goodness. Getting ready to push this out now.
Diffstat (limited to 'examples/blogpost/views.py')
-rw-r--r--examples/blogpost/views.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/blogpost/views.py b/examples/blogpost/views.py
index bfb53b5d..0377b447 100644
--- a/examples/blogpost/views.py
+++ b/examples/blogpost/views.py
@@ -1,33 +1,33 @@
from djangorestframework.response import Response, status
from djangorestframework.resource import Resource
from djangorestframework.modelresource import ModelResource, RootModelResource
-from blogpost.models import BlogPost, Comment
+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')
-class BlogPostRoot(RootModelResource):
+class BlogPosts(RootModelResource):
"""A resource with which lists all existing blog posts and creates new blog posts."""
- allowed_methods = ('GET', 'POST',)
- model = BlogPost
+ anon_allowed_methods = allowed_methods = ('GET', 'POST',)
+ model = models.BlogPost
fields = BLOG_POST_FIELDS
class BlogPostInstance(ModelResource):
"""A resource which represents a single blog post."""
- allowed_methods = ('GET', 'PUT', 'DELETE')
- model = BlogPost
+ anon_allowed_methods = allowed_methods = ('GET', 'PUT', 'DELETE')
+ model = models.BlogPost
fields = BLOG_POST_FIELDS
-class CommentRoot(RootModelResource):
+class Comments(RootModelResource):
"""A resource which lists all existing comments for a given blog post, and creates new blog comments for a given blog post."""
- allowed_methods = ('GET', 'POST',)
- model = Comment
+ anon_allowed_methods = allowed_methods = ('GET', 'POST',)
+ model = models.Comment
fields = COMMENT_FIELDS
class CommentInstance(ModelResource):
"""A resource which represents a single comment."""
- allowed_methods = ('GET', 'PUT', 'DELETE')
- model = Comment
+ anon_allowed_methods = allowed_methods = ('GET', 'PUT', 'DELETE')
+ model = models.Comment
fields = COMMENT_FIELDS