From e8f165f1f09a1578ce805e0a44117663aa172f71 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 21 Feb 2007 05:18:34 +0000 Subject: [PATCH] Added a comment to ModelChoiceField from [4552] git-svn-id: http://code.djangoproject.com/svn/django/trunk@4553 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django/newforms/models.py b/django/newforms/models.py index a92d8f9b89..616c7141e7 100644 --- a/django/newforms/models.py +++ b/django/newforms/models.py @@ -139,7 +139,11 @@ class ModelChoiceField(ChoiceField): if hasattr(self, '_choices'): return self._choices # Otherwise, execute the QuerySet in self.queryset to determine the - # choices dynamically. + # choices dynamically. Return a fresh QuerySetIterator that has not + # been consumed. Note that we're instantiating a new QuerySetIterator + # *each* time _get_choices() is called (and, thus, each time + # self.choices is accessed) so that we can ensure the QuerySet has not + # been consumed. return QuerySetIterator(self.queryset, self.empty_label, self.cache_choices) def _set_choices(self, value):