#[derive(Sortable)]
{
// Attributes available to this derive:
#[django]
}
sort
only.Expand description
Derive the Sortable
trait, creating suitable SorterClass
types.
This is only implemented for structs with named fields. No fields
will be available to use as sort orders, unless there are
annotations to indicate otherwise. The annotations use the
django
attribute, which has the following significant options
here:
-
#[django(rename="new_name")]
Expose the annotated member for sorting as `new_name instead of using its name in the source code. -
#[django(sort)]
The field, which must be [Ord], will be exposed as a sort order for the enclosing type. The ordering is taken directly from [Ord]. -
#[django(sort="name","age")]
The field has a type which is itselfSortable
. Expose this field as defining a sort order of the same name, and When sorting by this field make the order defined by the field’s own membername
, and then by its own memberage
as a secondary sort.