#36986: Add a hook to Serializer._value_from_field() for complex fields like
CompositePrimaryKey
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Vishy
Type: | Algo
Cleanup/optimization | Status: assigned
Component: Core | Version: dev
(Serialization) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):
For another serializer API concern, see
47651eadb8ca7aacddad41da4df64fd2af11faae which fixed handling of JSONField
in the XML serializer by special casing it. I didn't intend to address XML
serialization in this ticket, but it could be useful if the new API were
generic enough to clean that up as well.
And while I only intended to address serialization in this ticket, I found
that a deserialization hook is also likely needed. Not only does the
JSONField/XML patch demonstrate a need, but for the various embedded model
fields, the
[https://github.com/django/django/blob/f2169ef3688422d394d36007e320bac839117f0b/django/core/serializers/python.py#L209
field.to_python()] handling in the Python `Deserializer._handle_object()`
almost works, except that embedded subfields are serialized to the
database using `Field.column` instead of `Field.name` as you would expect
to find in fixtures. Thus, the correct deserialization for embedded model
fields is [https://github.com/mongodb/django-mongodb-
backend/blob/3960d2ae2f6fc83b8c941db56195350412f68e1c/django_mongodb_backend/fields/embedded_model.py#L89-L106
EmbeddedModelField.to_python()] but with
`field.to_python(value[field.name])` instead of
`field.to_python(value[field.column])`.
--
Ticket URL: <https://code.djangoproject.com/ticket/36986#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019d12c3153b-fb5a1a04-b7c0-4e26-a0d2-d396334ec93f-000000%40eu-central-1.amazonses.com.