Mercurial > public > bravenewsurf
annotate bns_website/news/models.py @ 40:5c0f9d80442e
I added a news template tag that's a blatant rip off of Chris' review one.
author | Bob Mourlam <bob.mourlam@gmail.com> |
---|---|
date | Sun, 06 Nov 2011 21:16:22 -0600 |
parents | 353ca3874f43 |
children | 9ce9f77d6cde |
rev | line source |
---|---|
bob@14 | 1 from django.db import models |
bob@23 | 2 from datetime import timedelta, datetime |
bob@14 | 3 |
bob@14 | 4 # Create your models here. |
bob@14 | 5 class News(models.Model): |
bob@14 | 6 """ |
bob@14 | 7 This model represents all the info we store about each news entry. |
bob@14 | 8 |
bob@14 | 9 """ |
bob@14 | 10 title = models.CharField(max_length=128) |
bob@14 | 11 date = models.DateTimeField() |
bob@14 | 12 content = models.TextField() |
bob@14 | 13 |
bob@14 | 14 # User field? |
bob@14 | 15 |
bob@14 | 16 |
bob@23 | 17 def is_new(self): |
bob@37 | 18 if datetime.now() - self.date <= timedelta(days=30): |
bob@23 | 19 return True |
bob@23 | 20 |
bob@23 | 21 return False |
bob@23 | 22 |
bob@14 | 23 |
bob@14 | 24 class Meta: |
bob@14 | 25 verbose_name_plural="News" |
bob@21 | 26 ordering = ['-date'] |
bob@14 | 27 |
bob@14 | 28 def __unicode__(self): |
bob@14 | 29 return self.title |