attr

attr is the configuration for specifying what Python attribute is read from or written to. Set it to None to make a Field/Column/etc that does not write or read from an attribute on the objects it works on. This is useful for displaying computed data without needing to pollute your model class with single use methods.

attr defaults to the name, so this:

class MyForm(Form):
    foo = Field()

is the same as:

class MyForm(Form):
    foo = Field(attr='foo')

attr values can be dunder paths:

class TrackTable(Table):
    artist_name = Column(attr='album__artist__name')

    class Meta:
        auto__model = Track
        auto__include = []
▼ Hide result

(Although this example is more idiomatically written with auto)