1 from django.db import models
 
   2 from django.conf import settings
 
   5     ('rst', 'reStructuredText'),
 
   9 class BlogEntry(models.Model):
 
  10     title = models.CharField(maxlength=150)
 
  11     islive = models.BooleanField()
 
  12     sections = models.ManyToManyField('BlogSection')
 
  13     format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
 
  14     slug = models.SlugField(prepopulate_from=("title",))
 
  15     publish_date = models.DateTimeField()
 
  16     content = models.TextField()
 
  19         return self.__unicode__()
 
  21     def __unicode__(self):
 
  22         return u'%s - %s' %(self.publish_date.strftime('%Y-%m-%d %H:%M'), self.title)
 
  24     def get_absolute_url(self):
 
  25         return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
 
  30 class BlogSection(models.Model):
 
  31     title = models.CharField(maxlength=150)
 
  32     slug = models.SlugField(prepopulate_from=("title",))
 
  35         return self.__unicode__()
 
  37     def __unicode__(self):
 
  38         return u'%s' %(self.title,)
 
  40     def get_absolute_url(self):
 
  41         return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)