Mixins

class src.django_listview_filters.mixins.FilterViewMixin
get_context_data(**kwargs)

Get the context for this view.

get_filter_by_name(filter_name: str) ListViewFilter

Return filter matching filter_name

Parameters:

filter_name (str) – name of filter

Returns:

Filter that matches filter_name

Return type:

ListViewFilter, None if no match found

get_filters_params(params: dict | None = None)

Return all params except IGNORED_PARAMS.

get_queryset()

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

Filters

Simple Choices Field Filter

class src.django_listview_filters.filters.ChoicesFieldListViewFilter(field, request, params, model, field_path)

For model fields that use dropdowns populated by static variables (not a foreign key).

choices(changelist)

Return choices ready to be output in the template.

‘changelist’ is the ChangeList to be displayed.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

Simple Foreign Key Filter

class src.django_listview_filters.filters.RelatedFieldListViewFilter(field, request, params, model, field_path)

For model fields that use a ForeignKey relationship. Not for m2m fields.

choices(changelist)

Return dictionaries for each choice in a filter.

<changelist> is a ListView.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

has_output()

Return True if some choices would be output for this filter.

property include_empty_choice

Return True if a “(None)” choice should be included, which filters out everything except empty relationships.

Dump (please ignore)

class src.django_listview_filters.filters.AllValuesFieldListFilter(field, request, params, model, field_path)
choices(changelist)

Return choices ready to be output in the template.

‘changelist’ is the ChangeList to be displayed.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

class src.django_listview_filters.filters.ChoicesFieldListViewFilter(field, request, params, model, field_path)

For model fields that use dropdowns populated by static variables (not a foreign key).

choices(changelist)

Return choices ready to be output in the template.

‘changelist’ is the ChangeList to be displayed.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

class src.django_listview_filters.filters.FieldListViewFilter(field, request, params, model, field_path)

Filter for simple choice fields. Doesn’t allow for multiple choice fields.

has_output()

Return True if some choices would be output for this filter.

queryset(request, queryset)

Return the filtered queryset.

class src.django_listview_filters.filters.ListViewFilter(request, params, model)

Base class for list view filters. Must create subclasses to provide specific functionality.

choices(changelist)

Return choices ready to be output in the template.

‘changelist’ is the ChangeList to be displayed.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

has_output()

Return True if some choices would be output for this filter.

queryset(request, queryset)

Return the filtered queryset.

class src.django_listview_filters.filters.RelatedFieldListViewFilter(field, request, params, model, field_path)

For model fields that use a ForeignKey relationship. Not for m2m fields.

choices(changelist)

Return dictionaries for each choice in a filter.

<changelist> is a ListView.

expected_parameters()

Return the list of parameter names that are expected from the request’s query string and that will be used by this filter.

has_output()

Return True if some choices would be output for this filter.

property include_empty_choice

Return True if a “(None)” choice should be included, which filters out everything except empty relationships.