diff options
author | Dan McGee <dan@archlinux.org> | 2010-09-08 00:23:55 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-09-08 00:23:55 -0500 |
commit | f637a1eb67ed906b936ef70c0c1d8572edfe5bd7 (patch) | |
tree | a039c5890c1b3017f3245eb518b05f35930f14b8 /news/models.py | |
parent | 4e193afcea1c6096c05338ee000447fed72eb7ba (diff) |
Move news model to an appropriate place
Never would have guessed it should actually be in news/models.py.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'news/models.py')
-rw-r--r-- | news/models.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/news/models.py b/news/models.py index e69de29b..c7cfc939 100644 --- a/news/models.py +++ b/news/models.py @@ -0,0 +1,23 @@ +from django.db import models +from django.contrib.auth.models import User + +class News(models.Model): + id = models.AutoField(primary_key=True) + author = models.ForeignKey(User, related_name='news_author') + postdate = models.DateField(auto_now_add=True) + title = models.CharField(max_length=255) + content = models.TextField() + + def get_absolute_url(self): + return '/news/%i/' % self.id + + def __unicode__(self): + return self.title + + class Meta: + db_table = 'news' + verbose_name_plural = 'news' + get_latest_by = 'postdate' + ordering = ['-postdate', '-id'] + +# vim: set ts=4 sw=4 et: |