Mercurial > public > bravenewsurf
annotate bns_website/news/models.py @ 31:9b62e4eef794
Now that we have HTML as review content, must avoid styling <ul> & <li> in review content.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 04 Nov 2011 20:08:45 -0500 |
parents | 1357c69e887d |
children | 353ca3874f43 |
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@23 | 18 if datetime.now() - self.date <= timedelta(days=3): |
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 |