Commits

Jesper Nøhr committed f13db4d

updating models.py, adding forms.py

Comments (0)

Files changed (2)

apps/blog/forms.py

+from django import forms
+from django.forms.widgets import * 
+
+from cx.apps.blog.models import Comment
+
+class CommentForm(forms.ModelForm):
+    class Meta:
+        model = Comment
+        fields = ('author', 'email', 'url', 'content', 'notify_me')
+    

apps/blog/models.py

 from django.db import models
 from django.db.models import permalink
 from datetime import datetime, date, timedelta
+from django.contrib import admin
 
 class Post(models.Model):
     title = models.CharField(max_length=255)
-    slug = models.SlugField(unique=True, prepopulate_from = ('title',))
+    slug = models.SlugField(unique=True)
     excerpt = models.TextField()
     content = models.TextField(blank=True, null=True)
     created_on = models.DateTimeField()
     def __unicode__(self):
         return u"%s" % ( self.title )
     
-    class Admin:
-        pass
+class PostAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('title',)}
     
 class Comment(models.Model):
     post = models.ForeignKey(Post, related_name='comments')
     def __unicode__(self):
         return u"Comment, post=%s, author=%s, when=%s" % (self.post, self.author, str(self.created_on))
         
-    class Admin:
-        pass
+class CommentAdmin(admin.ModelAdmin):
+    pass
 
 class Category(models.Model):
     name = models.CharField(max_length=255, unique=True)
     def __unicode__(self):
         return u"Category: %s" % self.name
     
-    class Admin:
-        pass
-    
+class CategoryAdmin(admin.ModelAdmin):
+    pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.