#[derive(FilterableWithPersianRug)]
{
// Attributes available to this derive:
#[django]
}
filter and persian-rug only.Expand description
Derive the FilterableWithContext trait for persian-rug 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 field 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 indjango-query. -
#[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.
The struct itself must also be annotated with the django
attribute, which gives the persian-rug constraints to apply to
to each derived impl:
-
#[django(persian_rug(context=Rug))]The persian-rug context type for this type isRug. -
#[django(persian_rug(context=C, access(Foo<C>)))]The persian-rug context type is the template parameterC. The context must provide access toFoo<C>.