You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
ghost
changed the title
[Question] How to override the to python and to db serialization and deserialization?
[Resolved] How to override the to python and to db serialization and deserialization?
Nov 7, 2022
Since you're going to use a library to generate the schema, I must alert you that django-jsonform doesn't support all the standard JSON schema features. We've implemented a custom spec which is more suitable for form generation, rather than JSON data validation.
For example, listing required fields in an array is not supported. To make a field required, you have to set the required keyword inside the field:
# won't work
{
...
'required': ['field1', 'field2', ...]
}
---# will work
{
...
'field1': {'required': True},
'field2': {'required': True}
}
Although, the final goal is to fully support the standard schema, but it's still quite some way off.
For my specific use case, I am combining your library with https://github.com/s-knibbs/dataclasses-jsonschema
So, I am trying to have it serialize/deserialize to/from the dataclass.
In the python code, I want to get a dataclass instance when I access
.field
and I also want to be able to do.field = dataclass_instance
I do not want to affect the behavior on Django Admin.
My attempt at overriding:
But it doesn't seem to do anything for the python code.
MyModel.objects.first().my_field
still returns a dictThe text was updated successfully, but these errors were encountered: