I have a model with fields.Nested() of another model. In the mashal_with() I have also set skip_none=True.
When that value is missing, it causes the marshaling to give me an dictionary where all the values are none, instead of omitting the dictionary completely or even just giving me an empty dictionary.
This is causing me issues because my return code differs depending on the instance, so sometimes my return will have some fields, and sometimes others. But marshalling forces all the fields to exist. And without marshal_with() I cannot get automatic documentation based on the models. I also send the dictionary values as **kwargs elsewhere, and them being filled with None (instead of not existing) is crashing the function.
If anyone has an idea for a workaround, please let me know
Welp, I just discovered that fields.Nested() has its OWN skip_none setting, which is set when the model is declared. Using THAT setting, allows me to finally achieve the result I want.
I have a model with fields.Nested() of another model. In the mashal_with() I have also set
skip_none=True
.When that value is missing, it causes the marshaling to give me an dictionary where all the values are none, instead of omitting the dictionary completely or even just giving me an empty dictionary.
This is causing me issues because my return code differs depending on the instance, so sometimes my return will have some fields, and sometimes others. But marshalling forces all the fields to exist. And without
marshal_with()
I cannot get automatic documentation based on the models. I also send the dictionary values as **kwargs elsewhere, and them being filled with None (instead of not existing) is crashing the function.If anyone has an idea for a workaround, please let me know