-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
39 lines (33 loc) · 1.07 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from django import forms
from .models import Comment, Post
classes = "form-control rounded-4"
class CommentSendingForm(forms.ModelForm):
class Meta:
model = Comment
fields = ('content',)
widgets = {'content': forms.Textarea(attrs={
'placeholder': 'Enter your comment',
'class': classes + " rounded-end-0",
'rows': '3',
'style': 'resize:none'
})}
class PostCreationForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title', 'caption', 'content')
widgets = {
'title': forms.TextInput(attrs={
'placeholder': 'Title of your post',
'class': classes
}),
'content': forms.ClearableFileInput(attrs={
'class': classes,
'accept': 'image/*'
}),
'caption': forms.Textarea(attrs={
'placeholder': 'Caption of your post',
'class': classes,
'rows': '4',
'style': 'resize:none'
})
}