Ticket #2265: iterator_choices.patch
File iterator_choices.patch, 1.4 KB (added by , 18 years ago) |
---|
-
django/db/models/fields/__init__.py
7 7 from django.utils.functional import curry, lazy 8 8 from django.utils.text import capfirst 9 9 from django.utils.translation import gettext, gettext_lazy, ngettext 10 import datetime, os, time 10 import datetime, os, time, itertools 11 11 12 12 class NOT_PROVIDED: 13 13 pass … … 80 80 self.prepopulate_from = prepopulate_from 81 81 self.unique_for_date, self.unique_for_month = unique_for_date, unique_for_month 82 82 self.unique_for_year = unique_for_year 83 self. choices = choices or []83 self._choices = choices or [] 84 84 self.radio_admin = radio_admin 85 85 self.help_text = help_text 86 86 self.db_column = db_column … … 321 321 def bind(self, fieldmapping, original, bound_field_class): 322 322 return bound_field_class(self, fieldmapping, original) 323 323 324 def _get_choices(self): 325 if hasattr(self._choices, 'next'): 326 choices, self._choices = itertools.tee(self._choices, 2) 327 else: 328 choices = self._choices 329 330 return choices 331 choices = property(_get_choices) 332 324 333 class AutoField(Field): 325 334 empty_strings_allowed = False 326 335 def __init__(self, *args, **kwargs):