-
Notifications
You must be signed in to change notification settings - Fork 18
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
Handling of None / null fields in to_json #6
Comments
@j4mie Is this project still active? Just a friendly, sincere question. Thanks very much for your time. |
Hi Jeff, Many thanks for opening the issue. I agree that the case of null data vs missing keys in the data should probably be handled better. Unfortunately I'm not actively maintaining micromodels at the moment. The project that I was using it for has now ended and so it's difficult for me to find the time to support it. I'd recommend looking at https://github.com/j2labs/dictshield or https://github.com/saymedia/remoteobjects as potential alternatives. If you'd like to open a pull request I'll take a look at it when I can, but I can't promise when that will be. Alternatively you can fork the project and install your version with Cheers |
Hello J4mie,
I totally understand. Thanks very much for filling me in. Surely I would do the same if I was in your position.
Ahh, I did not realize that, nice trick! I'll look into this as an appropriate route forwards, or the other projects you mentioned. Thanks again for your time, |
Hi JeffPaine, I am sure you have moved on by now but if you still want to work on this, or have solved this problem in a fork. I'd like to include your solution in the next release. |
Hello @ericmoritz , Thanks much for following up. I ultimately didn't end up attempting to fix this issue. I decided to go with a different solution. I appreciate you checking into it though! |
It appears that micromodels does not (in my humble opinion) properly handle
None
/null
fields when usingto_json
.Modifying micromodels to properly return
null
when usingto_json
appears fairly straightforward (and I would happily submit a pull request). Is there some good reason for using the current approach that I'm not aware of? Thanks,Example Code
Expected Result
Actual Result
charfield
returns""
integerfield
returns0
floatfield
returns0.0
booleanfield
returnsFalse
datetimefield
returnsAttributeError: 'NoneType' object has no attribute 'isoformat'
datefield
returnsTypeError: NoneType could not be serialized by DateField
timefield
returnsTypeError: NoneType could not be serialized by TimeField
The text was updated successfully, but these errors were encountered: