Python django_filters.CharFilter() Examples
The following are 2
code examples of django_filters.CharFilter().
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 figures with MIT License | 5 votes |
def char_method_filter(method): """ method is the method name string Check if old style first Pre v1: """ if hasattr(django_filters, 'MethodFilter'): return django_filters.MethodFilter(action=method) # pylint: disable=no-member else: return django_filters.CharFilter(method=method)
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']) )