surenkov / django-pydantic-field

Django JSONField with Pydantic models as a Schema
https://pypi.org/project/django-pydantic-field/
Other
116 stars 12 forks source link

Django serialization support #41

Closed amyasnikov closed 10 months ago

amyasnikov commented 10 months ago

Django has built-in serializers. To support serializing Django models which contain PydanticSchemaField it is necessary to re-implement value_from_object(). Without this fix Django serialization encounters errors if a model contains PydanticSchemaField fields.

surenkov commented 10 months ago

Hi @amyasnikov, thank you for pointing on this issue! Looks like the primary issue is in value_to_string method -- I pushed an update to your PR here. Also added some tests for it.

I think these changes will be released the next week -- master branch is already frozen for 0.3.0 release. In meantime I can backport it for 0.2.* branch.