Re: [Django] #35898: Cannot use base managers of related models in dumpdata command (was: dumpdata Command Fails on Model with Custom User Manager)

2 views
Skip to first unread message

Django

unread,
Nov 8, 2024, 6:11:29 AM11/8/24
to django-...@googlegroups.com
#35898: Cannot use base managers of related models in dumpdata command
-------------------------------------+-------------------------------------
Reporter: Lorenzo Martini | Owner: (none)
Type: New feature | Status: closed
Component: Core | Version: 5.1
(Serialization) |
Severity: Normal | Resolution: wontfix
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 Sarah Boyce):

* resolution: => wontfix
* status: new => closed
* summary: dumpdata Command Fails on Model with Custom User Manager =>
Cannot use base managers of related models in dumpdata command
* type: Bug => New feature

Comment:

Hi Lorenzo

I don't think this is a bug but a new feature potentially. I think the
issue can be roughly demonstrated like:

{{{
class CustomManager(models.Manager):
use_in_migrations = False

def get_queryset(self):
# This will fail!
return super().get_queryset().filter(author="Roald Dahl")

class CustomManagerModel(models.Model):
objects = CustomManager()


class NewModel(models.Model):
customs = models.ManyToManyField('CustomManagerModel',
related_name='new', blank=True)
}}}

Then you run `dumpdata` for `NewModel` with the `--all` flag
(https://docs.djangoproject.com/en/5.1/ref/django-admin/#cmdoption-
dumpdata-all) but this means you use the base manager for that model, not
all related models

I think this use case is quite niche but feel free to propose it on the
[https://forum.djangoproject.com/c/internals/5 Forum] and see if others
agree this should be supported
--
Ticket URL: <https://code.djangoproject.com/ticket/35898#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages