Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
0f2ceee0
Kaydet (Commit)
0f2ceee0
authored
Agu 02, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23151 -- Deprecated RegexField.error_message.
Thanks Baptiste Mispelon for the suggestion.
üst
44169a00
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
8 deletions
+31
-8
forms.py
django/contrib/flatpages/forms.py
+5
-2
fields.py
django/forms/fields.py
+6
-1
deprecation.txt
docs/internals/deprecation.txt
+2
-0
fields.txt
docs/ref/forms/fields.txt
+7
-4
1.8.txt
docs/releases/1.8.txt
+6
-0
test_fields.py
tests/forms_tests/tests/test_fields.py
+5
-1
No files found.
django/contrib/flatpages/forms.py
Dosyayı görüntüle @
0f2ceee0
...
@@ -8,8 +8,11 @@ class FlatpageForm(forms.ModelForm):
...
@@ -8,8 +8,11 @@ class FlatpageForm(forms.ModelForm):
url
=
forms
.
RegexField
(
label
=
_
(
"URL"
),
max_length
=
100
,
regex
=
r'^[-\w/\.~]+$'
,
url
=
forms
.
RegexField
(
label
=
_
(
"URL"
),
max_length
=
100
,
regex
=
r'^[-\w/\.~]+$'
,
help_text
=
_
(
"Example: '/about/contact/'. Make sure to have leading"
help_text
=
_
(
"Example: '/about/contact/'. Make sure to have leading"
" and trailing slashes."
),
" and trailing slashes."
),
error_message
=
_
(
"This value must contain only letters, numbers,"
error_messages
=
{
" dots, underscores, dashes, slashes or tildes."
))
"invalid"
:
_
(
"This value must contain only letters, numbers,"
" dots, underscores, dashes, slashes or tildes."
),
},
)
class
Meta
:
class
Meta
:
model
=
FlatPage
model
=
FlatPage
...
...
django/forms/fields.py
Dosyayı görüntüle @
0f2ceee0
...
@@ -25,7 +25,7 @@ from django.forms.widgets import (
...
@@ -25,7 +25,7 @@ from django.forms.widgets import (
from
django.utils
import
formats
from
django.utils
import
formats
from
django.utils.encoding
import
smart_text
,
force_str
,
force_text
from
django.utils.encoding
import
smart_text
,
force_str
,
force_text
from
django.utils.ipv6
import
clean_ipv6_address
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
import
six
from
django.utils.six.moves.urllib.parse
import
urlsplit
,
urlunsplit
from
django.utils.six.moves.urllib.parse
import
urlsplit
,
urlunsplit
from
django.utils.translation
import
ugettext_lazy
as
_
,
ungettext_lazy
from
django.utils.translation
import
ugettext_lazy
as
_
,
ungettext_lazy
...
@@ -531,6 +531,11 @@ class RegexField(CharField):
...
@@ -531,6 +531,11 @@ class RegexField(CharField):
"""
"""
# error_message is just kept for backwards compatibility:
# error_message is just kept for backwards compatibility:
if
error_message
is
not
None
:
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
=
kwargs
.
get
(
'error_messages'
)
or
{}
error_messages
[
'invalid'
]
=
error_message
error_messages
[
'invalid'
]
=
error_message
kwargs
[
'error_messages'
]
=
error_messages
kwargs
[
'error_messages'
]
=
error_messages
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
0f2ceee0
...
@@ -40,6 +40,8 @@ about each item can often be found in the release notes of two versions prior.
...
@@ -40,6 +40,8 @@ about each item can often be found in the release notes of two versions prior.
* ``django.template.resolve_variable`` will be removed.
* ``django.template.resolve_variable`` will be removed.
* The ``error_message`` argument of ``django.forms.RegexField`` will be removed.
.. _deprecation-removed-in-1.9:
.. _deprecation-removed-in-1.9:
1.9
1.9
...
...
docs/ref/forms/fields.txt
Dosyayı görüntüle @
0f2ceee0
...
@@ -805,10 +805,13 @@ For each field, we describe the default widget used if you don't specify
...
@@ -805,10 +805,13 @@ For each field, we describe the default widget used if you don't specify
Also takes ``max_length`` and ``min_length``, which work just as they do for
Also takes ``max_length`` and ``min_length``, which work just as they do for
``CharField``.
``CharField``.
The optional argument ``error_message`` is also accepted for backwards
.. deprecated:: 1.8
compatibility. The preferred way to provide an error message is to use the
``error_messages`` argument, passing a dictionary with ``'invalid'`` as a key
The optional argument ``error_message`` is also accepted for backwards
and the error message as the value.
compatibility but will be removed in Django 2.0. The preferred way to
provide an error message is to use the :attr:`~Field.error_messages`
argument, passing a dictionary with ``'invalid'`` as a key and the error
message as the value.
``SlugField``
``SlugField``
~~~~~~~~~~~~~
~~~~~~~~~~~~~
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
0f2ceee0
...
@@ -625,3 +625,9 @@ The function has been informally marked as "Deprecated" for some time. Replace
...
@@ -625,3 +625,9 @@ The function has been informally marked as "Deprecated" for some time. Replace
It provided the :ttag:`lorem` template tag which is now included in the
It provided the :ttag:`lorem` template tag which is now included in the
built-in tags. Simply remove ``'django.contrib.webdesign'`` from
built-in tags. Simply remove ``'django.contrib.webdesign'`` from
:setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
:setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
``error_message`` argument to ``django.forms.RegexField``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It provided backwards compatibility for pre-1.0 code, but its functionality is
redundant. Use ``Field.error_messages['invalid']`` instead.
tests/forms_tests/tests/test_fields.py
Dosyayı görüntüle @
0f2ceee0
...
@@ -32,6 +32,7 @@ import re
...
@@ -32,6 +32,7 @@ import re
import
os
import
os
from
decimal
import
Decimal
from
decimal
import
Decimal
from
unittest
import
skipIf
from
unittest
import
skipIf
import
warnings
try
:
try
:
from
PIL
import
Image
from
PIL
import
Image
...
@@ -630,7 +631,10 @@ class FieldsTests(SimpleTestCase):
...
@@ -630,7 +631,10 @@ class FieldsTests(SimpleTestCase):
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a valid value.'"
,
f
.
clean
,
'2A2 '
)
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a valid value.'"
,
f
.
clean
,
'2A2 '
)
def
test_regexfield_4
(
self
):
def
test_regexfield_4
(
self
):
f
=
RegexField
(
'^[0-9][0-9][0-9][0-9]$'
,
error_message
=
'Enter a four-digit number.'
)
# deprecated error_message argument; remove in Django 2.0
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
f
=
RegexField
(
'^[0-9][0-9][0-9][0-9]$'
,
error_message
=
'Enter a four-digit number.'
)
self
.
assertEqual
(
'1234'
,
f
.
clean
(
'1234'
))
self
.
assertEqual
(
'1234'
,
f
.
clean
(
'1234'
))
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a four-digit number.'"
,
f
.
clean
,
'123'
)
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a four-digit number.'"
,
f
.
clean
,
'123'
)
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a four-digit number.'"
,
f
.
clean
,
'abcd'
)
self
.
assertRaisesMessage
(
ValidationError
,
"'Enter a four-digit number.'"
,
f
.
clean
,
'abcd'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment