[Django] #35898: dumpdata Command Fails on Model with Custom User Manager

7 views
Skip to first unread message

Django

unread,
Nov 8, 2024, 3:48:30 AM11/8/24
to django-...@googlegroups.com
#35898: dumpdata Command Fails on Model with Custom User Manager
-------------------------------------+-------------------------------------
Reporter: Lorenzo Martini | Type: Bug
Status: new | Component: Core
| (Serialization)
Version: 5.1 | Severity: Normal
Keywords: dumpdata chunk_size | Triage Stage:
iterator prefetch_related user | Unreviewed
base_manager default_manager |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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!
--
Ticket URL: <https://code.djangoproject.com/ticket/35898>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 8, 2024, 3:48:43 AM11/8/24
to django-...@googlegroups.com
#35898: dumpdata Command Fails on Model with Custom User Manager
-------------------------------------+-------------------------------------
Reporter: Lorenzo Martini | Owner: (none)
Type: Bug | Status: new
Component: Core | Version: 5.1
(Serialization) |
Severity: Normal | Resolution:
Keywords: dumpdata chunk_size | Triage Stage:
iterator prefetch_related user | Unreviewed
base_manager default_manager |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Lorenzo Martini):

* Attachment "django-dumpdata-bug.zip" added.

Django

unread,
Nov 8, 2024, 4:07:19 AM11/8/24
to django-...@googlegroups.com
#35898: dumpdata Command Fails on Model with Custom User Manager
-------------------------------------+-------------------------------------
Reporter: Lorenzo Martini | Owner: (none)
Type: Bug | Status: new
Component: Core | Version: 5.1
(Serialization) |
Severity: Normal | Resolution:
Keywords: dumpdata chunk_size | Triage Stage:
iterator prefetch_related user | Unreviewed
base_manager default_manager |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Lorenzo Martini:

Old 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!

New 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 custom 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!

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35898#comment:1>
Reply all
Reply to author
Forward
0 new messages