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

datetime.now() as a default value

Sergey Vilgelm edited this page Mar 19, 2018 · 1 revision
import datetime

import marshmallow_objects as marshmallow


class DateTimeModel(marshmallow.Model):
    datetime = marshmallow.fields.DateTime(
        missing=lambda: datetime.datetime.now().isoformat()
    )


print(DateTimeModel().datetime)
print(DateTimeModel(datetime='2000-01-01T23:59:42').datetime)

# 2018-03-12 16:19:01
# 2000-01-01 23:59:42
Clone this wiki locally