Opened 8 years ago
Closed 8 years ago
#26717 closed New feature (fixed)
Allow customizing stream attribute of Serializer for custom serializers
Reported by: | Berker Peksag | Owned by: | Berker Peksag |
---|---|---|---|
Component: | Core (Serialization) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Berker Peksag | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, Serializer.serialize()
sets self.stream
to io.StringIO
if stream
is not passed to django.core.serializers.serializer()
: https://github.com/django/django/blob/31a9a965a36c5ce923692e5dac430ea6a1cbf2a0/django/core/serializers/base.py#L69
However, when implementing or using a custom serializer we either tell the users to pass stream=io.BytesIO()
everytime they use it or need to make some unnecessary subclassing.
It would be nice to define a Serializer.stream
attribute similar to Serializer.progress_class
.
I noticed this while creating a msgpack serializer to understand what needs to be done in #15091.
I already have a patch to implement my proposal.
Change History (5)
comment:1 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 8 years ago
Has patch: | set |
---|
comment:4 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
https://github.com/django/django/pull/6743