Browse Source

Refs #8760 -- Removed "list" message for ModelMultipleChoiceField per deprecation timeline.

Mariusz Felisiak 4 years ago
parent
commit
bf770cc825

+ 0 - 9
django/forms/models.py

@@ -2,7 +2,6 @@
 Helper functions for creating Form classes from Django models
 and database field objects.
 """
-import warnings
 from itertools import chain
 
 from django.core.exceptions import (
@@ -15,7 +14,6 @@ from django.forms.utils import ErrorList
 from django.forms.widgets import (
     HiddenInput, MultipleHiddenInput, RadioSelect, SelectMultiple,
 )
-from django.utils.deprecation import RemovedInDjango40Warning
 from django.utils.text import capfirst, get_text_list
 from django.utils.translation import gettext, gettext_lazy as _
 
@@ -1313,13 +1311,6 @@ class ModelMultipleChoiceField(ModelChoiceField):
 
     def __init__(self, queryset, **kwargs):
         super().__init__(queryset, empty_label=None, **kwargs)
-        if self.error_messages.get('list') is not None:
-            warnings.warn(
-                "The 'list' error message key is deprecated in favor of "
-                "'invalid_list'.",
-                RemovedInDjango40Warning, stacklevel=2,
-            )
-            self.error_messages['invalid_list'] = self.error_messages['list']
 
     def to_python(self, value):
         if not value:

+ 0 - 4
docs/ref/forms/fields.txt

@@ -1347,10 +1347,6 @@ generating choices. See :ref:`iterating-relationship-choices` for details.
 
         Same as :class:`ModelChoiceField.iterator`.
 
-.. deprecated:: 3.1
-
-    The ``list`` message is deprecated, use ``invalid_list`` instead.
-
 .. _iterating-relationship-choices:
 
 Iterating relationship choices

+ 2 - 0
docs/releases/4.0.txt

@@ -301,3 +301,5 @@ to remove usage of these features.
   doesn't accept ``None``.
 
 * The ``providing_args`` argument for ``django.dispatch.Signal`` is removed.
+
+* The ``list`` message for ``ModelMultipleChoiceField`` is removed.

+ 1 - 23
tests/forms_tests/tests/test_error_messages.py

@@ -8,8 +8,7 @@ from django.forms import (
     SplitDateTimeField, TimeField, URLField, utils,
 )
 from django.template import Context, Template
-from django.test import SimpleTestCase, TestCase, ignore_warnings
-from django.utils.deprecation import RemovedInDjango40Warning
+from django.test import SimpleTestCase, TestCase
 from django.utils.safestring import mark_safe
 
 from ..models import ChoiceModel
@@ -309,24 +308,3 @@ class ModelChoiceFieldErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
         self.assertFormErrors(['REQUIRED'], f.clean, '')
         self.assertFormErrors(['NOT A LIST OF VALUES'], f.clean, '3')
         self.assertFormErrors(['4 IS INVALID CHOICE'], f.clean, ['4'])
-
-
-class DeprecationTests(TestCase, AssertFormErrorsMixin):
-    @ignore_warnings(category=RemovedInDjango40Warning)
-    def test_list_error_message(self):
-        f = ModelMultipleChoiceField(
-            queryset=ChoiceModel.objects.all(),
-            error_messages={'list': 'NOT A LIST OF VALUES'},
-        )
-        self.assertFormErrors(['NOT A LIST OF VALUES'], f.clean, '3')
-
-    def test_list_error_message_warning(self):
-        msg = (
-            "The 'list' error message key is deprecated in favor of "
-            "'invalid_list'."
-        )
-        with self.assertRaisesMessage(RemovedInDjango40Warning, msg):
-            ModelMultipleChoiceField(
-                queryset=ChoiceModel.objects.all(),
-                error_messages={'list': 'NOT A LIST OF VALUES'},
-            )