after

Ordering of fields and columns is based on the declared order, the order in the model (when using auto), and the after configuration. The last takes precedent over the others.

To order fields, you supply either the name of a field, an index, or the special value LAST to put a field last.

Using after is especially useful when you already have a complex object that you want to add one or a few fields to in some specific position.

form = Form(
    auto__model=Album,
    fields__name__after=LAST,
    fields__year__after='artist',
    fields__artist__after=0,
)
▼ Hide result

This will make the field order artist, year, name.

If there are multiple fields with the same index or name the order of the fields will be used to disambiguate.