-
Notifications
You must be signed in to change notification settings - Fork 33
/
form_renderers.py
30 lines (20 loc) · 931 Bytes
/
form_renderers.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
from django.forms.renderers import TemplatesSetting
class BulmaFormRenderer(TemplatesSetting):
form_template_name = "forms/bulma/div.html"
single_field_row_template = "forms/bulma/field_row.html"
class BulmaFormMixin:
default_renderer = BulmaFormRenderer()
do_htmx_validation = False # Set to True in subclasses
def __init__(self, *args, **kwargs) -> None:
return super().__init__(*args, label_suffix="", **kwargs)
def get_context(self, *args, **kwargs):
return super().get_context(*args, **kwargs) | {
"do_htmx_validation": self.do_htmx_validation,
"single_field_row_template": self.renderer.single_field_row_template,
}
# Pure currently unused
class PureFormRenderer(TemplatesSetting):
form_template_name = "forms/pure/div.html"
class PureFormMixin:
default_renderer = PureFormRenderer()
template_name_label = "forms/pure/label.html"