Skip to content

Instantly share code, notes, and snippets.

@mmtechslv
Created April 7, 2021 15:48
Show Gist options
  • Save mmtechslv/5e3598f680b69a4f74f6695370e8d083 to your computer and use it in GitHub Desktop.
Save mmtechslv/5e3598f680b69a4f74f6695370e8d083 to your computer and use it in GitHub Desktop.
Markdium-Introduction
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