Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

using class Meta

Sergey Vilgelm edited this page Mar 26, 2018 · 1 revision
import marshmallow_objects as marshmallow


class Album(marshmallow.Model):
    title = marshmallow.fields.Str()
    release_date = marshmallow.fields.Date()


class AlbumOrdered(Album):
    class Meta:
        ordered = True


album = dict(title="Beggars Banquet", release_date='1968-12-6')
data1 = Album(**album).dump()
data2 = AlbumOrdered(**album).dump()

print(data1)
print(data2)

# {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}
# OrderedDict([('title', 'Beggars Banquet'), ('release_date', '1968-12-06')])
Clone this wiki locally