Kaydet (Commit) fa534b92 authored tarafından Thomas Chaumeny's avatar Thomas Chaumeny Kaydeden (comit) Tim Graham

Fixed #23623 -- Reduced memory consumption when generating ModelChoiceField choices

üst 115c3071
......@@ -1083,12 +1083,12 @@ class ModelChoiceIterator(object):
if self.field.cache_choices:
if self.field.choice_cache is None:
self.field.choice_cache = [
self.choice(obj) for obj in self.queryset.all()
self.choice(obj) for obj in self.queryset.iterator()
]
for choice in self.field.choice_cache:
yield choice
else:
for obj in self.queryset.all():
for obj in self.queryset.iterator():
yield self.choice(obj)
def __len__(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment