]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blobdiff - sommitrealweird/blog/models.py
Update for newer django
[sommitrealweird.git] / sommitrealweird / blog / models.py
index 6b0d2544f7630eed51f5f6ef40b1b970399afbcf..9548a32b5b2a4fc1c445109c0292cd9a0b516fa3 100644 (file)
@@ -1,5 +1,6 @@
 from django.db import models
 from django.conf import settings
 from django.db import models
 from django.conf import settings
+from django.contrib import admin
 
 FORMAT_CHOICES = (
     ('rst', 'reStructuredText'),
 
 FORMAT_CHOICES = (
     ('rst', 'reStructuredText'),
@@ -7,11 +8,11 @@ FORMAT_CHOICES = (
 )
 
 class BlogEntry(models.Model):
 )
 
 class BlogEntry(models.Model):
-    title = models.CharField(maxlength=150)
-    islive = models.BooleanField()
+    title = models.CharField(max_length=150)
+    islive = models.BooleanField(default=False)
     sections = models.ManyToManyField('BlogSection')
     sections = models.ManyToManyField('BlogSection')
-    format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
-    slug = models.SlugField(prepopulate_from=("title",))
+    format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
+    slug = models.SlugField()
     publish_date = models.DateTimeField()
     content = models.TextField()
 
     publish_date = models.DateTimeField()
     content = models.TextField()
 
@@ -24,12 +25,12 @@ class BlogEntry(models.Model):
     def get_absolute_url(self):
         return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
 
     def get_absolute_url(self):
         return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
 
-    class Admin:
-        pass
+    class Meta:
+        ordering = ['-publish_date']
 
 class BlogSection(models.Model):
 
 class BlogSection(models.Model):
-    title = models.CharField(maxlength=150)
-    slug = models.SlugField(prepopulate_from=("title",))
+    title = models.CharField(max_length=150)
+    slug = models.SlugField()
 
     def __str__(self):
         return self.__unicode__()
 
     def __str__(self):
         return self.__unicode__()
@@ -39,6 +40,3 @@ class BlogSection(models.Model):
 
     def get_absolute_url(self):
         return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
 
     def get_absolute_url(self):
         return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
-
-    class Admin:
-        pass