fairdm.contrib.autocomplete.filters#
Filters that narrow a list by the records of one kind, chosen with a counted control.
Module Contents#
Classes#
Narrow a list to the records that point at any of several chosen records. |
|
Narrow a list to the records that carry any of several chosen tags. |
API#
- class RecordMultipleFilter(field_class, *, scope='public', **kwargs)#
Bases:
django_filters.ModelMultipleChoiceFilterNarrow a list to the records that point at any of several chosen records.
The control is the multiple record field of one kind, at
publicscope unless told otherwise, so a visitor and a signed-in researcher are offered the same records. The field validates what it is sent against its view, never against the page’s search.Args: field_class: The multiple record field to draw, such as
DatasetMultipleChoiceField. scope: How much the person may be offered. Defaults to"public". **kwargs: Passed toModelMultipleChoiceFilter. Aquerysetis not taken: the field’s view decides what is offered.Example:
python dataset = RecordMultipleFilter(DatasetMultipleChoiceField, field_name="dataset")Initialization
- property field#
Build the field and hand it the filter set’s request.
- for_api()#
Return the plain filter the API uses in place of this one.
The API matches records by short identifier and has no control to draw, so it takes a plain model filter over the records this filter offers at its scope.
Returns: A
ModelMultipleChoiceFilterover the same relation.
- class TagFilter(*, scope='public', **kwargs)#
Bases:
django_filters.FilterNarrow a list to the records that carry any of several chosen tags.
The control is the tags field with no way to add a tag, at
publicscope unless told otherwise, so a visitor and a signed-in researcher are offered the same tags.Args: scope: How much the person may be offered. Defaults to
"public". **kwargs: Passed toFilter.field_namenames the tag’s name, such as"tags__name".Example:
python tags = TagFilter(field_name="tags__name")Initialization
- field_class#
None
- property field#
Build the field and hand it the filter set’s request.