summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-08-02 18:33:18 -0400
committerTim Graham <timograham@gmail.com>2014-08-03 11:21:01 -0400
commit0f2ceee0254349ee4ac7d472d3efe67ee161a917 (patch)
tree557f664c5fc08c1b85f213b62c98f1ad776a7bf1 /django
parent44169a00c1fe7c130a8b9774e3b02ccce524a3eb (diff)
Fixed #23151 -- Deprecated RegexField.error_message.
Thanks Baptiste Mispelon for the suggestion.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/flatpages/forms.py7
-rw-r--r--django/forms/fields.py7
2 files changed, 11 insertions, 3 deletions
diff --git a/django/contrib/flatpages/forms.py b/django/contrib/flatpages/forms.py
index 8d85922d9d..6e7448c397 100644
--- a/django/contrib/flatpages/forms.py
+++ b/django/contrib/flatpages/forms.py
@@ -8,8 +8,11 @@ class FlatpageForm(forms.ModelForm):
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
help_text=_("Example: '/about/contact/'. Make sure to have leading"
" and trailing slashes."),
- error_message=_("This value must contain only letters, numbers,"
- " dots, underscores, dashes, slashes or tildes."))
+ error_messages={
+ "invalid": _("This value must contain only letters, numbers,"
+ " dots, underscores, dashes, slashes or tildes."),
+ },
+ )
class Meta:
model = FlatPage
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 6e44ccfbb7..36f13472eb 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -25,7 +25,7 @@ from django.forms.widgets import (
from django.utils import formats
from django.utils.encoding import smart_text, force_str, force_text
from django.utils.ipv6 import clean_ipv6_address
-from django.utils.deprecation import RemovedInDjango19Warning
+from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
@@ -531,6 +531,11 @@ class RegexField(CharField):
"""
# error_message is just kept for backwards compatibility:
if error_message is not None:
+ warnings.warn(
+ "The 'error_message' argument is deprecated. Use "
+ "Field.error_messages['invalid'] instead.",
+ RemovedInDjango20Warning, stacklevel=2
+ )
error_messages = kwargs.get('error_messages') or {}
error_messages['invalid'] = error_message
kwargs['error_messages'] = error_messages