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

Serializer Field: default=0 gets ignored #282

Open
acu192 opened this issue Jun 24, 2021 · 1 comment
Open

Serializer Field: default=0 gets ignored #282

acu192 opened this issue Jun 24, 2021 · 1 comment

Comments

@acu192
Copy link

acu192 commented Jun 24, 2021

Because of this line:

if model_field.default and not isinstance(model_field, me_fields.ComplexBaseField):

If default is "falsy" (like if you do default=0 on an IntField) then the default is ignored.

@acu192
Copy link
Author

acu192 commented Jun 24, 2021

A workaround is to do default=lambda: 0 on your ME fields, instead of just the simple default=0.

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

1 participant