Mercurial > public > madeira
diff news/models.py @ 71:e2868ad47a1e
For Django 1.4, using the new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Apr 2012 16:40:29 -0500 |
parents | madeira/news/models.py@966cde8635c0 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/news/models.py Sat Apr 14 16:40:29 2012 -0500 @@ -0,0 +1,29 @@ +""" +Models for the news application. + +""" +from django.db import models + + +class News(models.Model): + """ + This model represents all the info we store about each news entry. + + """ + title = models.CharField(max_length=128, blank=True) + date = models.DateTimeField(db_index=True) + content = models.TextField() + + def __unicode__(self): + date_str = self.date.strftime('%m/%d/%Y') + if self.title: + return u'%s %s' % (date_str, self.title) + return u'%s' % date_str + + @models.permalink + def get_absolute_url(self): + return ('news-item', [], {'pk': str(self.id)}) + + class Meta: + verbose_name_plural = 'News' + ordering = ['-date']