comparison bns_website/news/models.py @ 23:1357c69e887d

- I added a little New badge for posts in the last 3 days. - I added a <div class=""> tag to the news posts to group them within the same Bootstrap CSS alert block. I'm not sure if it's a good idea or not, but it's kind of cool.
author Bob Mourlam <bob.mourlam@gmail.com>
date Mon, 31 Oct 2011 22:08:45 -0500
parents 687af3cb0525
children 353ca3874f43
comparison
equal deleted inserted replaced
22:6cb0d49187ae 23:1357c69e887d
1 from django.db import models 1 from django.db import models
2 from datetime import timedelta, datetime
2 3
3 # Create your models here. 4 # Create your models here.
4 class News(models.Model): 5 class News(models.Model):
5 """ 6 """
6 This model represents all the info we store about each news entry. 7 This model represents all the info we store about each news entry.
11 content = models.TextField() 12 content = models.TextField()
12 13
13 # User field? 14 # User field?
14 15
15 16
17 def is_new(self):
18 if datetime.now() - self.date <= timedelta(days=3):
19 return True
20
21 return False
22
16 23
17 class Meta: 24 class Meta:
18 verbose_name_plural="News" 25 verbose_name_plural="News"
19 ordering = ['-date'] 26 ordering = ['-date']
20 27