We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If we have a pydantic model with any Pydantic specific fields, then the model will not be properly serialized and the crash will appear.
For instance:
import pydantic import django_pydantic_field class MyModel(pydantic.BaseModel): my_url: pydantic.HttpUrl = pydantic.HttpUrl('https://example.com/') obj = MyModel() field = django_pydantic_field.SchemaField(schema=MyModel) field.get_prep_value(obj)
And the output will be:
TypeError: Object of type Url is not JSON serializable
It can be fixed if we use the mode=json when we perform _prepare_raw_value inside get_prep_value like this:
mode=json
_prepare_raw_value
get_prep_value
def get_prep_value(self, value: t.Any): value = self._prepare_raw_value(value, mode='json') return super().get_prep_value(value)
Or am I missing something?
The text was updated successfully, but these errors were encountered:
Yep, you're absolutely correct, thank you for reporting this!
I've prepared the fix in #57, will release it under the next patch.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
If we have a pydantic model with any Pydantic specific fields, then the model will not be properly serialized and the crash will appear.
For instance:
And the output will be:
It can be fixed if we use the
mode=json
when we perform_prepare_raw_value
insideget_prep_value
like this:Or am I missing something?
The text was updated successfully, but these errors were encountered: