Allow setting None to NestedModel field
See original GitHub issueHi,
I’m setting up my models like this
from fireo import models
class NestedModel(models.Model):
a = models.TextField()
class TestingTheModel(models.Model):
nested = models.NestedModel(NestedModel, required=False, default=None)
b = models.TextField()
class Meta:
ignore_none_field = True
and then saving the model:
TestingTheModel(nested=None, b='xd').save()
The Firestore document after this operation:
{
"nested": {},
"b": "xd"
}
I would like to get this data in Firestore:
{
"nested": None,
"b": "xd"
}
Any tips on how this could be achieved?
I am more than happy to have any solution to his problem: adding parameters, CustomField, extending NestedModel etc. works for me.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How do i use nested model with none value in pydantic
You have the same model name and field name Emails , this leads to an error. Give a different name for example:
Read more >Body - Nested Models - FastAPI
With FastAPI, you can define, validate, document, and use arbitrarily deeply nested models (thanks to Pydantic). List fields¶. You can define an attribute...
Read more >Serializers - Django REST framework - Tom Christie
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered...
Read more >Response marshalling - Flask-RESTPlus - Read the Docs
By default when the sub-object is None , an object with default values for the nested fields will be generated instead of null...
Read more >Nested query | Elasticsearch Guide [8.5] | Elastic
Wraps another query to search nested fields. The nested query searches nested field objects as if they were indexed as separate documents.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wrote this “flexible” NestedModelField that has been working quite well for me, allows for repeated nested model as well. Saves things as None, Dict or List[Dict]
@monthero Thanks for your effort for creating this
FlexibleNestedModelField
it will be great if you send a PR for this I will merge it. Name it properly instead ofFlexibleNestedModelField
and if you can write docs for how to use it will be helpful for other.Fireo Docs