Commits

Cédric Bonhomme committed 4457158

Added Category model for posts.

Comments (0)

Files changed (2)

 # -*- coding: utf-8 -*-
 from cedricbonhomme.blog.models import Post
 from cedricbonhomme.blog.models import Comment
+from cedricbonhomme.blog.models import Category
 from django.contrib import admin
 
 
 class PostAdmin(admin.ModelAdmin):
-    fields = ['title', 'content_html', 'content']
+    fields = ['title', 'content_html', 'content', 'category']
 
 admin.site.register(Post, PostAdmin)
 
 
-
 class CommentAdmin(admin.ModelAdmin):
     display_fields = ["post", "author", "created"]
 
-admin.site.register(Comment, CommentAdmin)
+admin.site.register(Comment, CommentAdmin)
+
+
+class CategoryAdmin(admin.ModelAdmin):
+    fields = ['title', 'description']
+
+admin.site.register(Category, CategoryAdmin)
     
     created = models.DateTimeField(auto_now_add=True)
 
-
+    category = models.ForeignKey('blog.Category')
 
 
     def __unicode__(self):
 
 
     def __unicode__(self):
-        return unicode("%s: %s" % (self.post, self.content[:60]))
+        return unicode("%s: %s" % (self.post, self.content[:60]))
+
+
+class Category(models.Model):
+    title = models.CharField(max_length=60, db_index=True)
+    description = models.CharField(max_length=200, db_index=True)
+
+    def __unicode__(self):
+        return self.title