Skip to content
Browse files

Added a comment to ModelChoiceField from [4552]

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent ee96c7e commit e8f165f1f09a1578ce805e0a44117663aa172f71 @adrianholovaty adrianholovaty committed
Showing with 5 additions and 1 deletion.
  1. +5 −1 django/newforms/
6 django/newforms/
@@ -139,7 +139,11 @@ def _get_choices(self):
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):

0 comments on commit e8f165f

Please sign in to comment.
Something went wrong with that request. Please try again.