|
1
|
from django import forms |
|
2
|
|
|
3
|
from .models import Page |
|
4
|
|
|
5
|
tw = "w-full rounded-md border-gray-300 shadow-sm focus:border-brand focus:ring-brand sm:text-sm" |
|
6
|
|
|
7
|
|
|
8
|
class PageForm(forms.ModelForm): |
|
9
|
class Meta: |
|
10
|
model = Page |
|
11
|
fields = ["name", "content", "is_published"] |
|
12
|
widgets = { |
|
13
|
"name": forms.TextInput(attrs={"class": tw, "placeholder": "Page title"}), |
|
14
|
"content": forms.Textarea(attrs={"class": tw + " font-mono", "rows": 20, "placeholder": "Write in Markdown..."}), |
|
15
|
"is_published": forms.CheckboxInput(attrs={"class": "rounded border-gray-300 text-brand"}), |
|
16
|
} |
|
17
|
|