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

More options around exclude_if_none #233

Open
venkat-raman-wday opened this issue Nov 13, 2024 · 1 comment
Open

More options around exclude_if_none #233

venkat-raman-wday opened this issue Nov 13, 2024 · 1 comment

Comments

@venkat-raman-wday
Copy link

As noted in the document, the exclude_if_none is based off of Falsey-ness. While this might apply to most property types, it also doesn't apply in certain conditions to certain properties. For example, for an IntegerProperty, setting exclude_if_none=True doesn't work for cases where default=0 which is a valid value for this property and ends up being wrong. When generating a JSON based off of default values and validating against a schema, these cases make a big difference. There probably are other such scenarios. Any workarounds for this?

@venkat-raman-wday
Copy link
Author

Well, I found a work around by overriding to_json() and checking the values of the keys in _obj's value. Any suggestions is welcome. I'd also like to know if there are private attributes where meta information for the attributes is stored so that I end up checking attributes for only certain property types.

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