django_ufilter.backends.plain module¶
- class django_ufilter.backends.plain.PlainFilterBackend(queryset, context=None)[source]¶
Bases:
django_ufilter.backends.base.BaseFilterBackend
Filter backend for filtering plain Python iterables.
Warning
The filter backend does filtering inside a regular loop by comparing attributes of individual objects within iterable. As a result, this is NOT efficient method for filtering any large amounts of data. In those cases, it would probably be better to find more appropriate and efficient way to filter data.
- enforce_same_models = False¶
Whether same models should be enforced when trying to use this filter backend.
More can be found in
BaseFilterBackend.model()
- filter_by_specs(queryset)[source]¶
Filter queryset by applying all filter specifications
The filtering is done by calling manually loping over all items in the iterable and comparing inner attributes with the filter specification.
- get_model()[source]¶
Get the model from the given queryset
Since there is no specific model for filtering Python lists, this simply returns
object
- name = 'plain'¶
Name of the filter backend.
This is used by custom callable filters to define callables for each supported backend. More at
CallableFilter
- supported_lookups = {'contains', 'day', 'endswith', 'exact', 'gt', 'gte', 'hour', 'icontains', 'iendswith', 'iexact', 'iin', 'in', 'iregex', 'isnull', 'istartswith', 'lt', 'lte', 'minute', 'month', 'range', 'regex', 'second', 'startswith', 'week_day', 'year'}¶
Set of supported lookups this filter backend supports.
This is used by leaf
Filter
to determine whether it should constructFilterSpec
for a particular key-value pair from querystring since it if constructs specification but then filter backend will not be able to filter it, things will blow up. By explicitly checking if filter backend supports particular lookup it can short-circuit the logic and avoid errors down the road. This is pretty much the only coupling between filters and filter backends.