diff options
| author | Thomas Chaumeny <thomas.chaumeny@polyconseil.fr> | 2014-10-09 13:02:25 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-10-10 09:50:02 -0400 |
| commit | fa534b92dda0771661a98a1ca302ced264d0a6da (patch) | |
| tree | f27fde52be4d0bf75dd5b9e87bafd2064d259d55 | |
| parent | 115c307184d441fbc27a8f43a99af5d992cfcc13 (diff) | |
Fixed #23623 -- Reduced memory consumption when generating ModelChoiceField choices
| -rw-r--r-- | django/forms/models.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index b23d815775..acb7f91a76 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -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): |
