#[derive(Filterable)]
{
// Attributes available to this derive:
#[django]
}
filter only.Expand description
Derive the Filterable trait, creating suitable FilterClass
types.
This is only implemented for structs with named fields. All fields
will be exposed, with a default operator of exact unless annotated
to indicate otherwise. The annotations use the django attribute,
which has the following options:
-
#[django(rename="new_name")]Expose the annotated member for filtering as `new_name instead of using its name in the source code. -
#[django(default_op=iexact)]Set the default operator, which is applied when the field is referred to directly to beiexact, whereiexactcan be replaced with any of the built-in operators included in this crate. -
#[django(default_fun=my_crate::MyOperatorClass)]Set the default operator to be the custom typemy_crate::MyOperatorClass, which must implementOperatorClass.] -
#[django(exclude)]Do not expose this field, it cannot be used in filtering. -
#[django(traverse)]This type of this field is itselfFilterableand nested filters onto its members are permitted via the double underscore syntax that Django uses. -
#[django(op(in, icontains))]In addition to the default operator, this field can also be filtered on usinginandicontains, using double underscores to separate the operator from the field name. -
#[django(op(foo=my_crate::MyOperatorClass))]This field has a custom filter operatorfoowhich can be appended to its name with double underscores, and which when used, creates a filter usingmy_crate::MyOperatorClass, which must itself be an instance ofOperatorClass.