Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListType serialize_when_none=False doesn't seem to work #597

Open
trutia opened this issue Aug 1, 2019 · 1 comment
Open

ListType serialize_when_none=False doesn't seem to work #597

trutia opened this issue Aug 1, 2019 · 1 comment

Comments

@trutia
Copy link

trutia commented Aug 1, 2019

One of the fields in our model is ListType and is being set to None if though it is not being passed in.

@tirkarthi
Copy link
Contributor

Can you please attach a sample script to explain the current and expected behavior? I am trying out the below where serialize_when_none when set to True has the field in serialized value. When set to False doesn't have the field in the serialized value.

from schematics.models import Model
from schematics.types import StringType, ListType


class ModelB(Model):
    field1 = ListType(StringType(), serialize_when_none=True)
    field2 = ListType(StringType(), serialize_when_none=False)


model = ModelB()
print(model.serialize())
python samplelistnone.py
{'field1': None}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants