[Django] #36608: dumpdata does not use custom serializers

15 views
Skip to first unread message

Django

unread,
Sep 12, 2025, 3:40:10 PM (8 days ago) Sep 12
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: Ksauder | Type:
| Uncategorized
Status: new | Component: Core
| (Management commands)
Version: 5.2 | Severity: Release
| blocker
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
As displayed in the diff, the code was simply broken and always raised an
exception for custom serializer formats.
--
Ticket URL: <https://code.djangoproject.com/ticket/36608>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 12, 2025, 3:40:44 PM (8 days ago) Sep 12
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: Ksauder | Owner: (none)
Type: Uncategorized | Status: new
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution:
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ksauder):

* Attachment "dumpdata_fix.diff" added.

Django

unread,
Sep 12, 2025, 3:56:42 PM (8 days ago) Sep 12
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: Uncategorized | Status: new
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution:
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by ksauder:

Old description:

> As displayed in the diff, the code was simply broken and always raised an
> exception for custom serializer formats.

New description:

As displayed in the diff, the code was simply broken and always raised an
exception for custom serializer formats.

After further investigation, this problem could also be solved by adding
'internal_use_only = False' to the classes in the example here
https://docs.djangoproject.com/en/5.2/topics/serialization/#custom-
serialization-formats. This gets around the "if format in
serializers.get_public_serializer_formats()" check, although the old code
in the diff still doesn't make sense.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:1>

Django

unread,
Sep 13, 2025, 10:01:25 AM (8 days ago) Sep 13
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution: invalid
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* resolution: => invalid
* status: new => closed

Comment:

Hi there,

The code isn't broken, the exception should always be raised. The loop is
there to provide the chance to raise a more appropriate message rather
than "Unknown serialization format".

FYI this information was obtained by simply looking at git blame 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:2>

Django

unread,
Sep 13, 2025, 12:13:42 PM (7 days ago) Sep 13
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution: invalid
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by ksauder):

Well, the code is a little broken. It doesn't actually raise a more
appropriate message, and the docs do not actually point out that
`internal_use_only` flag must be unset for it to work from the command
line. I would suggest a change along the lines of this:


{{{
diff --git a/django/core/management/commands/dumpdata.py
b/django/core/management/commands/dumpdata.py
index 15e615c1d0..9ec9ab76a3 100644
--- a/django/core/management/commands/dumpdata.py
+++ b/django/core/management/commands/dumpdata.py
@@ -177,9 +177,8 @@ class Command(BaseCommand):
try:
serializers.get_serializer(format)
except serializers.SerializerDoesNotExist:
- pass
-
- raise CommandError("Unknown serialization format: %s" %
format)
+ raise CommandError("Unknown serialization format: %s" %
format)
+ # We found it, but it's not a public serializer. Let the user
know
+ raise CommandError("Serialization format %s is flagged for
internal_use_only. Set internal_use_only = False in the Serializer to use
it here." % format)

def get_objects(count_only=False):
"""
}}}

And/or call out the `internal_use_only` flag near the custom serialization
doc and its affect on CLI operation.
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:3>

Django

unread,
Sep 13, 2025, 12:23:46 PM (7 days ago) Sep 13
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution: invalid
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by David Sanders):

Doc updates are always welcome 👍 feel free to submit a doc PR for
clarification if you like. Also if you feel the error message is lacking
you're welcome to submit a PR for that too.

Just FYI you don't necessarily need a ticket for minor docs updates or
minor code clarification (for future reference)
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:4>

Django

unread,
Sep 13, 2025, 2:03:05 PM (7 days ago) Sep 13
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Management | Version: 5.2
commands) |
Severity: Release blocker | Resolution: invalid
Keywords: dumpdata custom | Triage Stage:
serializers | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by ksauder):

Rog, I'll put one together
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:5>

Django

unread,
Sep 15, 2025, 9:33:55 AM (6 days ago) Sep 15
to django-...@googlegroups.com
#36608: dumpdata does not use custom serializers
-------------------------------------+-------------------------------------
Reporter: ksauder | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: 5.2
commands) |
Severity: Normal | Resolution:
Keywords: dumpdata custom | Triage Stage: Accepted
serializers |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* resolution: invalid =>
* severity: Release blocker => Normal
* stage: Unreviewed => Accepted
* status: closed => new
* type: Uncategorized => Cleanup/optimization

Comment:

Reopening to track the docs clarifications. Also downgrading to not
release blocker.
--
Ticket URL: <https://code.djangoproject.com/ticket/36608#comment:6>
Reply all
Reply to author
Forward
0 new messages