1 from django.db import models
2 from django.conf import settings
3 from django.contrib import admin
6 ('rst', 'reStructuredText'),
10 class BlogEntry(models.Model):
11 title = models.CharField(max_length=150)
12 islive = models.BooleanField(default=False)
13 sections = models.ManyToManyField('BlogSection')
14 format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
15 slug = models.SlugField()
16 publish_date = models.DateTimeField()
17 content = models.TextField()
20 return self.__unicode__()
22 def __unicode__(self):
23 return u'%s - %s' %(self.publish_date.strftime('%Y-%m-%d %H:%M'), self.title)
25 def get_absolute_url(self):
26 return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
29 ordering = ['-publish_date']
31 class BlogSection(models.Model):
32 title = models.CharField(max_length=150)
33 slug = models.SlugField()
36 return self.__unicode__()
38 def __unicode__(self):
39 return u'%s' %(self.title,)
41 def get_absolute_url(self):
42 return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)