Dynastie/forms.py

41 lines
1.3 KiB
Python
Raw Normal View History

2012-07-08 16:23:39 +02:00
from django.forms import ModelForm
from django import forms
2012-07-08 16:23:39 +02:00
from dynastie.models import *
class BlogForm(ModelForm):
class Meta:
model = Blog
2012-08-28 09:09:14 +02:00
class PostForm(ModelForm):
description = forms.CharField(widget=forms.Textarea(attrs={'rows':'5', 'cols':'50'}), required=False)
keywords = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'50'}), required=False)
text_tags = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'50'}), required=False)
2012-07-08 16:23:39 +02:00
class Meta:
2012-08-28 09:09:14 +02:00
model = Post
2012-09-08 12:35:52 +02:00
exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags')
2012-07-08 16:23:39 +02:00
def __init__(self, *args, **kwargs):
2012-08-28 09:09:14 +02:00
super(PostForm, self).__init__(*args, **kwargs)
2012-07-08 16:23:39 +02:00
self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()]
class CategoryForm(ModelForm):
class Meta:
model = Category
2012-10-09 20:47:12 +02:00
exclude = ('parent', 'name_slug', 'blog')
2012-07-08 16:23:39 +02:00
class UserForm(ModelForm):
class Meta:
model = User
exclude = ('is_staff', 'is_active', 'last_login', 'last_joined', 'user_permissions', 'groups', 'date_joined')
2012-10-04 21:49:33 +02:00
class CommentForm(ModelForm):
class Meta:
model = Comment
exclude = ('post', 'parent', 'date')
class TagForm(ModelForm):
class Meta:
model = Tag
exclude = ('blog', 'name_slug')