Filter¶
Base class: Part
Class that describes a filter that you can search for.
See Query for more complete examples.
Parameters with the prefix field__ will be passed along downstream to the Field instance if applicable. This can be used to tweak the basic style interface.
Refinable members¶
after (evaluated)¶
Type: int | str
See after
assets¶
Type: Namespace
See assets
attr (evaluated)¶
See attr
- Cookbook:
choices (evaluated)¶
config_from_model¶
Type: Namespace
endpoints¶
Type: Namespace
See endpoints
extra¶
Type: dict[str, Any]
See extra
extra_evaluated¶
Type: dict[str, Any]
See extra
extra_params¶
See extra_params
field¶
Type: Namespace
freetext (evaluated)¶
include (evaluated)¶
Type: bool
See include
iommi_style¶
Type: str | Style | None
See iommi_style
is_valid_filter¶
Default: iommi.query.default_filter__is_valid_filter
model (evaluated)¶
Type: type[Model] | None
model_field¶
model_field_name¶
parse¶
pk_lookup_to_q¶
query_name (evaluated)¶
Default: lambda filter, **_: filter.iommi_name()
- Cookbook:
query_operator_for_field (evaluated)¶
Type: str
Default: =
query_operator_to_q_operator¶
search_fields¶
unary¶
value_to_q¶
- Cookbook:
Shortcuts¶
Filter.boolean¶
Defaults¶
field__call_target__attributeboolean
parseiommi.form.bool_parse
unaryTrue
query_operator_to_q_operatoriommi.query.boolean__query_operator_to_q_operator
Filter.boolean_tristate¶
Defaults¶
field__call_target__attributeboolean_tristate
parseiommi.form.boolean_tristate__parse
query_operator_to_q_operatoriommi.query.boolean__query_operator_to_q_operator
unaryTrue
Filter.case_sensitive¶
Defaults¶
query_operator_to_q_operatoriommi.query.case_sensitive_query_operator_to_q_operator
Filter.choice¶
Field that has one value out of a set.
Defaults¶
field__call_target__attributechoice
Filter.choice_queryset¶
Field that has one value out of a set.
Defaults¶
field__call_target__attributechoice_queryset
query_operator_to_q_operatorlambda op: 'exact'
value_to_qiommi.query.choice_queryset_value_to_q
is_valid_filteriommi.query.choice_queryset__is_valid_filter
Filter.date¶
Defaults¶
field__call_target__attributedate
parseiommi.form.date_parse
Filter.datetime¶
Defaults¶
field__call_target__attributedate
parseiommi.form.date_parse
extra_evaluated__is_tz_awarelambda **_: settings.USE_TZ
Filter.decimal¶
Parent: Filter.number
Defaults¶
field__call_target__attributedecimal
Filter.duration¶
Parent: Filter.text
Defaults¶
field__call_target__attributeduration
Filter.email¶
Defaults¶
field__call_target__attributeemail
Filter.file¶
Defaults¶
field__call_target__attributefile
Filter.float¶
Parent: Filter.number
Defaults¶
field__call_target__attributefloat
parseiommi.form.float_parse
Filter.foreign_key¶
Filter.foreign_key_reverse¶
Defaults¶
field__call_target__attributeforeign_key_reverse
extra__django_related_fieldTrue
Filter.integer¶
Parent: Filter.number
Defaults¶
field__call_target__attributeinteger
parseiommi.form.int_parse
Filter.many_to_many¶
Filter.many_to_many_reverse¶
Filter.multi_choice¶
Field that has one value out of a set.
Defaults¶
field__call_target__attributemulti_choice
Filter.multi_choice_queryset¶
Defaults¶
field__call_target__attributemulti_choice_queryset
Filter.number¶
Defaults¶
field__call_target__attributenumber
query_operator_to_q_operatoriommi.query.case_sensitive_query_operator_to_q_operator
Filter.text¶
Defaults¶
field__call_target__attributetext
query_operator_for_field:
Filter.textarea¶
Parent: Filter.text
Filter.time¶
Defaults¶
field__call_target__attributetime
parseiommi.form.time_parse
Filter.url¶
Defaults¶
field__call_target__attributeurl
Methods¶
on_bind¶
on_refine_done¶
own_evaluate_parameters¶
Class methods¶
checkboxes¶
from_model¶
Create a Filter from a Django model field.
When used declaratively inside a Query, you normally don’t need to pass anything:
the model is taken from the containing query and the model field name from the filter’s
own name. This works because resolution is deferred until the query is bound, by which
point both are known.
class AlbumQuery(Query):
name = Filter.from_model()
Pass attr (using __ to drill down) to read a field from a related model:
class AlbumQuery(Query):
artist_name = Filter.from_model(attr='artist__name')
The explicit model, model_field_name and model_field parameters are still
accepted for the rare cases where the field can’t be inferred from context (e.g. when
not declared on a query), but are no longer required.