* cc: Jacob Walls, Raphael Kimmig, Simon Charette (added)
* summary: dumpdata does not work in 5.0.1 on QuerySets with
prefetch_related => dumpdata crashes on querysets with
prefetch_related().
* severity: Normal => Release blocker
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. Does the following patch work for you?
{{{#!diff
diff --git a/django/core/management/commands/dumpdata.py
b/django/core/management/commands/dumpdata.py
index cc183517e3..01ff8974dd 100644
--- a/django/core/management/commands/dumpdata.py
+++ b/django/core/management/commands/dumpdata.py
@@ -219,7 +219,10 @@ class Command(BaseCommand):
if count_only:
yield queryset.order_by().count()
else:
- yield from queryset.iterator()
+ chunk_size = (
+ 2000 if queryset._prefetch_related_lookups
else None
+ )
+ yield from
queryset.iterator(chunk_size=chunk_size)
try:
self.stdout.ending = None
}}}
Regression in 139135627650ed6aaaf4c755b82c3bd43f2b8f51 (#29984).
--
Ticket URL: <https://code.djangoproject.com/ticket/35159#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.