diff options
| author | Tom Christie | 2011-05-02 19:49:12 +0100 | 
|---|---|---|
| committer | Tom Christie | 2011-05-02 19:49:12 +0100 | 
| commit | 8756664e064a18afc4713d921c318cd968f18433 (patch) | |
| tree | 8eb4499900552963f88972d0853e68d05159295f /examples | |
| parent | b358fbdbe9cbd4ce644c4b2c7b9b4cec0811e14e (diff) | |
| download | django-rest-framework-8756664e064a18afc4713d921c318cd968f18433.tar.bz2 | |
emitters -> renderers
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/blogpost/models.py | 5 | ||||
| -rw-r--r-- | examples/blogpost/views.py | 7 | ||||
| -rw-r--r-- | examples/mixin/urls.py | 2 | ||||
| -rw-r--r-- | examples/pygments_api/views.py | 2 | 
4 files changed, 9 insertions, 7 deletions
diff --git a/examples/blogpost/models.py b/examples/blogpost/models.py index 01a91e15..3489c596 100644 --- a/examples/blogpost/models.py +++ b/examples/blogpost/models.py @@ -12,6 +12,8 @@ RATING_CHOICES = ((0, 'Awful'),                    (3, 'Good'),                    (4, 'Excellent')) +MAX_POSTS = 10 +  class BlogPost(models.Model):      key = models.CharField(primary_key=True, max_length=64, default=uuid_str, editable=False)      title = models.CharField(max_length=128) @@ -38,9 +40,10 @@ class BlogPost(models.Model):      def save(self, *args, **kwargs):          self.slug = slugify(self.title)          super(self.__class__, self).save(*args, **kwargs) -        for obj in self.__class__.objects.order_by('-pk')[10:]: +        for obj in self.__class__.objects.order_by('-pk')[MAX_POSTS:]:              obj.delete() +  class Comment(models.Model):      blogpost = models.ForeignKey(BlogPost, editable=False, related_name='comments')      username = models.CharField(max_length=128) 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 diff --git a/examples/mixin/urls.py b/examples/mixin/urls.py index f4300f41..1d25f6c7 100644 --- a/examples/mixin/urls.py +++ b/examples/mixin/urls.py @@ -15,7 +15,7 @@ class ExampleView(ResponseMixin, View):      def get(self, request):          response = Response(200, {'description': 'Some example content',                                    'url': reverse('mixin-view')}) -        return self.emit(response) +        return self.render(response)  urlpatterns = patterns('', diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index 278e8250..253b0907 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -68,7 +68,7 @@ class PygmentsRoot(Resource):  class PygmentsInstance(Resource):      """Simply return the stored highlighted HTML file with the correct mime type. -    This Resource only emits HTML and uses a standard HTML renderer rather than the renderers.DocumentingHTMLRenderer class.""" +    This Resource only renders HTML and uses a standard HTML renderer rather than the renderers.DocumentingHTMLRenderer class."""      renderers = (HTMLRenderer,)      def get(self, request, unique_id):  | 
