view bns_website/news/models.py @ 79:548b9e61bd64

Updated bands.json to include "asset_prefix" tags for all the bands. Incorporated all the small images from Ferenc into the bands slideshow. Went through and crushed all the large images to fit within 800x600. Make sure to "manage.py loaddata bands.json" after picking this up.
author Chris Ridgway <ckridgway@gmail.com>
date Fri, 25 Nov 2011 16:54:59 -0600
parents 9ce9f77d6cde
children
line wrap: on
line source
from django.db import models
from datetime import timedelta, datetime
from django.core.urlresolvers import reverse

# Create your models here.
class News(models.Model):
    """
    This model represents all the info we store about each news entry.

    """
    title = models.CharField(max_length=128)
    date = models.DateTimeField()
    content = models.TextField()

    def __unicode__(self):
        return self.title

    def is_new(self):
        if datetime.now() - self.date <= timedelta(days=30):
            return True
        return False

    def get_absolute_url(self):
        return reverse('news') + '#news%d' % self.id

    class Meta:
        verbose_name_plural="News"
        ordering = ['-date']