Opened 7 days ago

Last modified 7 days ago

#35898 closed New feature

dumpdata Command Fails on Model with Custom User Manager — at Initial Version

Reported by: Lorenzo Martini Owned by:
Component: Core (Serialization) Version: 5.1
Severity: Normal Keywords: dumpdata chunk_size iterator prefetch_related user base_manager default_manager
Cc: Lorenzo Martini Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello Django Team,

I'm encountering an issue with the django-admin dumpdata command when trying to serialize a model with a ManyToMany relationship to a custom User model. This custom User model inherits from another User model defined in a different app.

It appears that Django is using the default manager of the custom User model, rather than its base manager. This base manager includes prefetch_related calls in its get_queryset function, which I suspect is causing the issue.

I've attached a Dockerized Django app that replicates this behavior. You can also find it on GitHub: https://github.com/Martini991/django-dumpdata-bug.

For reference, I’ve reviewed two related tickets, but they seem to address different issues:
https://code.djangoproject.com/ticket/35238
https://code.djangoproject.com/ticket/35159

Thank you for your assistance!

Change History (1)

by Lorenzo Martini, 7 days ago

Attachment: django-dumpdata-bug.zip added
Note: See TracTickets for help on using tickets.
Back to Top