blog/models.py @ 7e2a0c0282b3

Really, Firefox?  I actually have to tell you to inherit the font-weight for a *div*?
author Steve Losh <steve@stevelosh.com>
date Thu, 19 Mar 2009 20:53:53 -0400
parents a8bf2eea85f7
children dbf5fe560ec3
from django.db import models
import datetime

class Entry(models.Model):
    title = models.CharField(max_length=140)
    snip = models.CharField(max_length=140)
    slug = models.SlugField()
    pub_date = models.DateTimeField('Date Published', 
                                    default=datetime.datetime.now)
    body = models.TextField()
    published = models.BooleanField(default=False)
    
    class Meta:
        verbose_name = 'entry'
        verbose_name_plural = 'entries'
    
    @models.permalink
    def get_absolute_url(self):
        return ('blog-entry', (self.pub_date.year, self.pub_date.month, 
                               self.pub_date.day, self.slug),)
    
    def __unicode__(self):
        return u'%s' % (self.title,)

class Comment(models.Model):
    name = models.CharField('Commenter', blank=False, null=False, 
                            max_length=40)
    body = models.TextField('Comment', blank=False, null=False)
    submitted = models.DateTimeField(default=datetime.datetime.now)
    entry = models.ForeignKey(Entry)
    spam = models.BooleanField(default=False)
    
    def get_absolute_url(self):
        return self.entry.get_absolute_url() + "#comment-" + str(self.id)
    
    def __unicode__(self):
        return u'%s on %s' % (self.name, self.entry.title)