Python django_filters.BooleanFilter() Examples
The following are 2
code examples of django_filters.BooleanFilter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django_filters
, or try the search function
.
Example #1
Source File: filters.py From wagtail with BSD 3-Clause "New" or "Revised" License | 6 votes |
def filter_for_lookup(cls, field, lookup_type): filter_class, params = super().filter_for_lookup(field, lookup_type) if filter_class == django_filters.ChoiceFilter: params.setdefault('widget', ButtonSelect) params.setdefault('empty_label', _("All")) elif filter_class in [django_filters.DateFilter, django_filters.DateTimeFilter]: params.setdefault('widget', AdminDateInput) elif filter_class == django_filters.DateFromToRangeFilter: params.setdefault('widget', DateRangePickerWidget) elif filter_class == django_filters.BooleanFilter: params.setdefault('widget', BooleanButtonSelect) return filter_class, params
Example #2
Source File: filters.py From tom_base with GNU General Public License v3.0 | 5 votes |
def filter_for_field(field): if field['type'] == 'number': return django_filters.RangeFilter(field_name=field['name'], method=filter_number) elif field['type'] == 'boolean': return django_filters.BooleanFilter(field_name=field['name'], method=filter_boolean) elif field['type'] == 'datetime': return django_filters.DateTimeFromToRangeFilter(field_name=field['name'], method=filter_datetime) elif field['type'] == 'string': return django_filters.CharFilter(field_name=field['name'], method=filter_text) else: raise ValueError( 'Invalid field type {}. Field type must be one of: number, boolean, datetime string'.format(field['type']) )