summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-01-17 13:48:46 -0500
committerTim Graham <timograham@gmail.com>2015-01-17 13:48:46 -0500
commit2788c46d46bc4d7afb906765ce1f484faef180c5 (patch)
treeb751a736f4d8bdf5730d435018b8abcb7fd3c3e7
parent4b8d3bbab58ee99404fc84091fcca566552322ea (diff)
Removed Multiple/ModelChoiceField cache_choices option; refs #22838.
-rw-r--r--django/forms/models.py30
1 files changed, 6 insertions, 24 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 1ec1398147..8475c6eb11 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -1078,16 +1078,8 @@ class ModelChoiceIterator(object):
def __iter__(self):
if self.field.empty_label is not None:
yield ("", self.field.empty_label)
- if self.field.cache_choices:
- if self.field.choice_cache is None:
- self.field.choice_cache = [
- self.choice(obj) for obj in self.queryset.iterator()
- ]
- for choice in self.field.choice_cache:
- yield choice
- else:
- for obj in self.queryset.iterator():
- yield self.choice(obj)
+ for obj in self.queryset.iterator():
+ yield self.choice(obj)
def __len__(self):
return (len(self.queryset) +
@@ -1106,7 +1098,7 @@ class ModelChoiceField(ChoiceField):
' the available choices.'),
}
- def __init__(self, queryset, empty_label="---------", cache_choices=None,
+ def __init__(self, queryset, empty_label="---------",
required=True, widget=None, label=None, initial=None,
help_text='', to_field_name=None, limit_choices_to=None,
*args, **kwargs):
@@ -1114,13 +1106,6 @@ class ModelChoiceField(ChoiceField):
self.empty_label = None
else:
self.empty_label = empty_label
- if cache_choices is not None:
- warnings.warn("cache_choices has been deprecated and will be "
- "removed in Django 1.9.",
- RemovedInDjango19Warning, stacklevel=2)
- else:
- cache_choices = False
- self.cache_choices = cache_choices
# Call Field instead of ChoiceField __init__() because we don't need
# ChoiceField.__init__().
@@ -1128,7 +1113,6 @@ class ModelChoiceField(ChoiceField):
*args, **kwargs)
self.queryset = queryset
self.limit_choices_to = limit_choices_to # limit the queryset later.
- self.choice_cache = None
self.to_field_name = to_field_name
def get_limit_choices_to(self):
@@ -1222,12 +1206,10 @@ class ModelMultipleChoiceField(ModelChoiceField):
'invalid_pk_value': _('"%(pk)s" is not a valid value for a primary key.')
}
- def __init__(self, queryset, cache_choices=None, required=True,
- widget=None, label=None, initial=None,
- help_text='', *args, **kwargs):
+ def __init__(self, queryset, required=True, widget=None, label=None,
+ initial=None, help_text='', *args, **kwargs):
super(ModelMultipleChoiceField, self).__init__(queryset, None,
- cache_choices, required, widget, label, initial, help_text,
- *args, **kwargs)
+ required, widget, label, initial, help_text, *args, **kwargs)
def to_python(self, value):
if not value: