diff options
Diffstat (limited to 'src/testapp')
| -rw-r--r-- | src/testapp/models.py | 14 | ||||
| -rw-r--r-- | src/testapp/views.py | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/testapp/models.py b/src/testapp/models.py index 32d9a612..909788a3 100644 --- a/src/testapp/models.py +++ b/src/testapp/models.py @@ -40,8 +40,8 @@ RATING_CHOICES = ((0, 'Awful'), class BlogPost(models.Model): key = models.CharField(primary_key=True, max_length=64, default=uuid_str, editable=False) - title = models.CharField(max_length=128, help_text='The article title (Required)') - content = models.TextField(help_text='The article body (Required)') + title = models.CharField(max_length=128) + content = models.TextField() created = models.DateTimeField(auto_now_add=True) slug = models.SlugField(editable=False, default='') @@ -74,11 +74,14 @@ class BlogPost(models.Model): class Comment(models.Model): blogpost = models.ForeignKey(BlogPost, editable=False, related_name='comments') - username = models.CharField(max_length=128, help_text='Please enter a username (Required)') - comment = models.TextField(help_text='Enter your comment here (Required)') - rating = models.IntegerField(blank=True, null=True, choices=RATING_CHOICES, help_text='Please rate the blog post (Optional)') + username = models.CharField(max_length=128) + comment = models.TextField() + rating = models.IntegerField(blank=True, null=True, choices=RATING_CHOICES, help_text='How did you rate this post?') created = models.DateTimeField(auto_now_add=True) + class Meta: + ordering = ('created',) + @models.permalink def get_absolute_url(self): return ('testapp.views.CommentInstance', (self.blogpost.key, self.id)) @@ -86,5 +89,6 @@ class Comment(models.Model): @property @models.permalink def blogpost_url(self): + """Link to the blog post resource which this comment corresponds to.""" return ('testapp.views.BlogPostInstance', (self.blogpost.key,)) diff --git a/src/testapp/views.py b/src/testapp/views.py index dee0b19b..82539435 100644 --- a/src/testapp/views.py +++ b/src/testapp/views.py @@ -1,4 +1,5 @@ -from rest.resource import Resource, ModelResource, QueryModelResource +from rest.resource import Resource +from rest.modelresource import ModelResource, QueryModelResource from testapp.models import BlogPost, Comment ##### Root Resource ##### |
