#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 Vishy Algo):
We can Introduce a format-aware serialization registry on
{{{django.db.models.Field}}} mapping serializer formats ('python', 'xml',
etc.) to handler callables. To support recursive execution, the callable
signature must accept the active serializer instance as context:
{{{handler(field, obj, serializer)}}}.
This allows the removal of hardcoded isinstance checks within the core
serializers. For example, CompositePrimaryKey will encapsulate its
serialization compilation via the registry:
{{{CompositePrimaryKey.register_serializer_handler('python',
composite_python_serializer)}}}
Similarly, with the JSON field
{{{JSONField.register_serializer_handler('xml', json_xml_serializer)}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36986#comment:7>
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/0107019d16ac4751-27aeaf05-ab40-43be-a297-a4eb746d3af3-000000%40eu-central-1.amazonses.com.