aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blogpost/urls.py
diff options
context:
space:
mode:
authorTom Christie2011-05-23 17:07:31 +0100
committerTom Christie2011-05-23 17:07:31 +0100
commitc53175914752502629141556f3e001e9d2e9f7fa (patch)
treed68bc4f0b2baeed2a90d6d20295423583603ba2b /examples/blogpost/urls.py
parente7f8c06dbbbc9e4ae91327ee02cd8147777b17e2 (diff)
downloaddjango-rest-framework-c53175914752502629141556f3e001e9d2e9f7fa.tar.bz2
name and description
Diffstat (limited to 'examples/blogpost/urls.py')
-rw-r--r--examples/blogpost/urls.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/blogpost/urls.py b/examples/blogpost/urls.py
index 130363b1..c677b8fa 100644
--- a/examples/blogpost/urls.py
+++ b/examples/blogpost/urls.py
@@ -6,7 +6,11 @@ from djangorestframework.resources import ModelResource
from blogpost.models import BlogPost, Comment
+
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',)
@@ -14,7 +18,11 @@ class BlogPostResource(ModelResource):
def comments(self, instance):
return reverse('comments', kwargs={'blogpost': instance.key})
+
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',)
@@ -25,4 +33,4 @@ urlpatterns = patterns('',
url(r'^(?P<key>[^/]+)/$', InstanceModelView.as_view(resource=BlogPostResource)),
url(r'^(?P<blogpost>[^/]+)/comments/$', ListOrCreateModelView.as_view(resource=CommentResource), name='comments'),
url(r'^(?P<blogpost>[^/]+)/comments/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=CommentResource)),
-) \ No newline at end of file
+)