26 lines
909 B
Python
26 lines
909 B
Python
from django import forms
|
|
from .models import Post, Comment
|
|
|
|
|
|
class PostForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Post
|
|
fields = ['type', 'department', 'title', 'body', 'image', 'attachment']
|
|
widgets = {
|
|
'type': forms.Select(attrs={'class': 'form-select'}),
|
|
'department': forms.Select(attrs={'class': 'form-select'}),
|
|
'title': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'body': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}),
|
|
'image': forms.ClearableFileInput(attrs={'class': 'form-control'}),
|
|
'attachment': forms.ClearableFileInput(attrs={'class': 'form-control'}),
|
|
}
|
|
|
|
|
|
class CommentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Comment
|
|
fields = ['text']
|
|
widgets = {
|
|
'text': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}),
|
|
}
|