python version 3.7, marshmallow 3.1.1
class userSchema(Schema):
created_datetime = fields.Str(required=False, missing=str(datetime.datetime.now()))
name = fields.Str()
for i in range(3):
time.sleep(5)
user_data = {"name": "test"}
test_load = userSchema.load(user_data)
print(test_load)
I found the loaded data are all with the same created_datetime whereas I expect them to be different. Is this the case that missing and default can only be a fixed value?
You need to provide a callable that accepts no arguments to generate a dynamic default/missing value. For example, using your code above: