Mercurial > public > madeira
annotate news/models.py @ 119:685e14392326
Bootstrap: style pagination.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Oct 2013 16:20:49 -0500 |
parents | e2868ad47a1e |
children |
rev | line source |
---|---|
bgneal@45 | 1 """ |
bgneal@45 | 2 Models for the news application. |
bgneal@45 | 3 |
bgneal@45 | 4 """ |
bgneal@45 | 5 from django.db import models |
bgneal@45 | 6 |
bgneal@45 | 7 |
bgneal@45 | 8 class News(models.Model): |
bgneal@45 | 9 """ |
bgneal@45 | 10 This model represents all the info we store about each news entry. |
bgneal@45 | 11 |
bgneal@45 | 12 """ |
bgneal@45 | 13 title = models.CharField(max_length=128, blank=True) |
bgneal@45 | 14 date = models.DateTimeField(db_index=True) |
bgneal@45 | 15 content = models.TextField() |
bgneal@45 | 16 |
bgneal@45 | 17 def __unicode__(self): |
bgneal@45 | 18 date_str = self.date.strftime('%m/%d/%Y') |
bgneal@45 | 19 if self.title: |
bgneal@45 | 20 return u'%s %s' % (date_str, self.title) |
bgneal@45 | 21 return u'%s' % date_str |
bgneal@45 | 22 |
bgneal@45 | 23 @models.permalink |
bgneal@45 | 24 def get_absolute_url(self): |
bgneal@45 | 25 return ('news-item', [], {'pk': str(self.id)}) |
bgneal@45 | 26 |
bgneal@45 | 27 class Meta: |
bgneal@45 | 28 verbose_name_plural = 'News' |
bgneal@45 | 29 ordering = ['-date'] |