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
3569ba03
Kaydet (Commit)
3569ba03
authored
Agu 05, 2016
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27015 -- Prevented HTML-invalid minlength/maxlength on hidden inputs
üst
6a8372e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
fields.py
django/forms/fields.py
+2
-2
test_charfield.py
tests/forms_tests/field_tests/test_charfield.py
+5
-2
No files found.
django/forms/fields.py
Dosyayı görüntüle @
3569ba03
...
...
@@ -236,10 +236,10 @@ class CharField(Field):
def
widget_attrs
(
self
,
widget
):
attrs
=
super
(
CharField
,
self
)
.
widget_attrs
(
widget
)
if
self
.
max_length
is
not
None
:
if
self
.
max_length
is
not
None
and
not
widget
.
is_hidden
:
# The HTML attribute is maxlength, not max_length.
attrs
[
'maxlength'
]
=
str
(
self
.
max_length
)
if
self
.
min_length
is
not
None
:
if
self
.
min_length
is
not
None
and
not
widget
.
is_hidden
:
# The HTML attribute is minlength, not min_length.
attrs
[
'minlength'
]
=
str
(
self
.
min_length
)
return
attrs
...
...
tests/forms_tests/field_tests/test_charfield.py
Dosyayı görüntüle @
3569ba03
from
__future__
import
unicode_literals
from
django.forms
import
(
CharField
,
PasswordInput
,
Textarea
,
TextInput
,
ValidationError
,
CharField
,
HiddenInput
,
PasswordInput
,
Textarea
,
TextInput
,
ValidationError
,
)
from
django.test
import
SimpleTestCase
...
...
@@ -79,7 +79,9 @@ class CharFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def
test_charfield_widget_attrs
(
self
):
"""
CharField.widget_attrs() always returns a dictionary (#15912).
CharField.widget_attrs() always returns a dictionary and includes
minlength/maxlength if min_length/max_length are defined on the field
and the widget is not hidden.
"""
# Return an empty dictionary if max_length and min_length are both None.
f
=
CharField
()
...
...
@@ -104,6 +106,7 @@ class CharFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
self
.
assertEqual
(
f
.
widget_attrs
(
TextInput
()),
{
'maxlength'
:
'10'
,
'minlength'
:
'5'
})
self
.
assertEqual
(
f
.
widget_attrs
(
PasswordInput
()),
{
'maxlength'
:
'10'
,
'minlength'
:
'5'
})
self
.
assertEqual
(
f
.
widget_attrs
(
Textarea
()),
{
'maxlength'
:
'10'
,
'minlength'
:
'5'
})
self
.
assertEqual
(
f
.
widget_attrs
(
HiddenInput
()),
{})
def
test_charfield_strip
(
self
):
"""
...
...
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