#33086: Postgres Contrib ArrayField raises error on serialization with
"django.core.serializers.json"
-------------------------------------+-------------------------------------
Reporter: Anudeep | Owner: < anudeepsamaiya >
Samaiya |
Type: Bug | Status: assigned
Component: | Version: 3.2
contrib.postgres |
Severity: Normal | Keywords: postgres, json
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
The encoder is not supported currently, which causes the serialization of
uuid fields missing.
'''Current Implementation:'''
{{{#!python
def value_to_string(self, obj):
values = []
vals = self.value_from_object(obj)
base_field = self.base_field
for val in vals:
if val is None:
values.append(None)
else:
obj = AttributeSetter(base_field.attname, val)
values.append(base_field.value_to_string(obj))
return json.dumps(values)
}}}
'''Suggested Implementation:'''
{{{#!python
def value_to_string(self, obj, encoder=DjangoJSONEncoder):
values = []
vals = self.value_from_object(obj)
base_field = self.base_field
for val in vals:
if val is None:
values.append(None)
else:
obj = AttributeSetter(base_field.attname, val)
values.append(base_field.value_to_string(obj))
return json.dumps(values, cls=encoder)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33086>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/057.2148c2b107df33a69f5730f3d772e390%40djangoproject.com.