django_ufilter.backends.django module

class django_ufilter.backends.django.DjangoFilterBackend(queryset, context=None)[source]

Bases: django_ufilter.backends.base.BaseFilterBackend

Filter backend for filtering Django querysets.

Warning

The filter backend can ONLY filter Django’s QuerySet. Passing any other datatype for filtering will kill happy bunnies under rainbow.

empty()[source]

Get empty queryset

property excludes

Property which gets list of negated filters

By combining all negated filters we can optimize filtering by calling QuerySet.exclude once rather then calling it for each filter specification.

filter_by_specs(queryset)[source]

Filter queryset by applying all filter specifications

The filtering is done by calling QuerySet.filter and QuerySet.exclude as appropriate.

get_model()[source]

Get the model from the given queryset

property includes

Property which gets list of non-negated filters

By combining all non-negated filters we can optimize filtering by calling QuerySet.filter once rather then calling it for each filter specification.

name = 'django'

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', 'date', 'day', 'endswith', 'exact', 'gt', 'gte', 'hour', 'icontains', 'iendswith', 'iexact', 'in', 'iregex', 'isnull', 'istartswith', 'len', '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 construct FilterSpec 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.