Mercurial > public > madeira
comparison 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 |
comparison
equal
deleted
inserted
replaced
70:f26cdda0ad8b | 71:e2868ad47a1e |
---|---|
1 """ | |
2 Models for the news application. | |
3 | |
4 """ | |
5 from django.db import models | |
6 | |
7 | |
8 class News(models.Model): | |
9 """ | |
10 This model represents all the info we store about each news entry. | |
11 | |
12 """ | |
13 title = models.CharField(max_length=128, blank=True) | |
14 date = models.DateTimeField(db_index=True) | |
15 content = models.TextField() | |
16 | |
17 def __unicode__(self): | |
18 date_str = self.date.strftime('%m/%d/%Y') | |
19 if self.title: | |
20 return u'%s %s' % (date_str, self.title) | |
21 return u'%s' % date_str | |
22 | |
23 @models.permalink | |
24 def get_absolute_url(self): | |
25 return ('news-item', [], {'pk': str(self.id)}) | |
26 | |
27 class Meta: | |
28 verbose_name_plural = 'News' | |
29 ordering = ['-date'] |