Created
April 7, 2021 15:48
-
-
Save mmtechslv/5e3598f680b69a4f74f6695370e8d083 to your computer and use it in GitHub Desktop.
Markdium-Introduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from crispy_forms.helper import FormHelper | |
from crispy_forms.bootstrap import StrictButton | |
from crispy_forms.layout import Field, Layout | |
from django import forms | |
from django_filters.fields import RangeField | |
class PeopleFilterFormHelper(forms.Form): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.helper = FormHelper(self) | |
self.helper.form_method = 'get' | |
layout_fields = [] | |
for field_name, field in self.fields.items(): | |
if isinstance(field, RangeField): | |
layout_field = Field(field_name, template="forms/fields/range-slider.html") | |
else: | |
layout_field = Field(field_name) | |
layout_fields.append(layout_field) | |
layout_fields.append(StrictButton("Submit", name='submit', type='submit', css_class='btn btn-fill-out btn-block mt-1')) | |
self.helper.layout = Layout(*layout_fields) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment