marshmallow
marshmallow copied to clipboard
Why is `ordered=True` not the default for Schemas?
In order to iterate over a schema's fields in the order in which it was defined, you have to add a class Meta: ordered=True
.
from marshmallow import Schema, fields
class FooSchema(Schema):
id = fields.Int()
bar_id = fields.Int()
baz_id = fields.Int()
creation_date = fields.DateTime()
last_updated_date = fields.DateTime()
class Meta:
ordered = True
for field_name in FooSchema().fields:
print(field_name)
Why isn't ordered=True the default?
See #1744 (and #1896).