Filter Reference¶
- class rest_filters.filters.Filter¶
- __init__(f: Field | None = None, /, *, field: str | BaseExpression | Combinable | None = None, lookup: str = '', template: Q | None = None, group: str | None = None, negate: bool = False, method: str | None = None, aliases: dict[str, Any] | None = None, param: str | None = None, children: list[Filter] | None = None, namespace: bool = False, blank: str | None = None, noop: bool = False, required: bool | None = None) None¶
A data descriptor for query parameters.
- Parameters:
f – The serializer field that will parse this query parameter. This can be left empty if
FilterSet.get_serializeris used to dynamically resolve the serializer field. A child filter may also omit this, in which case the parent serializer field is used.field – A string (field name) or Django expression that determines the database field/expression that is going to be filtered against. Child filters will inherit this value.
lookup – The lookup that will be used with the resolved database field.
template – A
Qobject that determines query expression for this parameter. For example,Q("username") | Q("email")will match the username or email field.group – Group identifier for this filter. Child filters will inherit their parent’s group (if set).
negate – Set this to
Trueto negate the resolved query expression.method – A method on the current FilterSet class that is going to determine the query expression for this filter.
aliases – Additional expressions that are going to be added to the QuerySet.
param – The name of this query parameter.
children – A list of filters that reside under the namespace of this filter.
namespace – When enabled, marks this filter as namespace and disables it. Only the child filters belonging to this filter will be available.
blank – Determines
rest_filters.conf.AppSettings.BLANKbehavior for this filter.noop – Set this to
Trueto disable query expression resolution. In this mode, the query parameter won’t do any filtering however, its value will be validated and available.required – Set this to
Trueto make this parameter required.