1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

Fixed #22838 -- Deprecated ModelChoiceField.cache_choices.

Undocumented, untested and probably not even useful feature.
This commit is contained in:
Marc Tamlyn
2014-06-15 12:02:39 +01:00
parent 97adfc2bf8
commit 2764146586
3 changed files with 22 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ and database field objects.
from __future__ import unicode_literals
from collections import OrderedDict
import warnings
from django.core.exceptions import (
ImproperlyConfigured, ValidationError, NON_FIELD_ERRORS, FieldError)
@@ -16,6 +17,7 @@ from django.forms.utils import ErrorList
from django.forms.widgets import (SelectMultiple, HiddenInput,
MultipleHiddenInput)
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import smart_text, force_text
from django.utils.text import get_text_list, capfirst
from django.utils.translation import ugettext_lazy as _, ugettext
@@ -1092,7 +1094,7 @@ class ModelChoiceField(ChoiceField):
' the available choices.'),
}
def __init__(self, queryset, empty_label="---------", cache_choices=False,
def __init__(self, queryset, empty_label="---------", cache_choices=None,
required=True, widget=None, label=None, initial=None,
help_text='', to_field_name=None, limit_choices_to=None,
*args, **kwargs):
@@ -1100,6 +1102,12 @@ 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
@@ -1191,7 +1199,7 @@ class ModelMultipleChoiceField(ModelChoiceField):
'invalid_pk_value': _('"%(pk)s" is not a valid value for a primary key.')
}
def __init__(self, queryset, cache_choices=False, required=True,
def __init__(self, queryset, cache_choices=None, required=True,
widget=None, label=None, initial=None,
help_text='', *args, **kwargs):
super(ModelMultipleChoiceField, self).__init__(queryset, None,