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
83a185a3
Kaydet (Commit)
83a185a3
authored
Tem 05, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Ensured bound field renders as unicode safe data
Refs #22950. Backport of
92090492
from master.
üst
b68c7a5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
forms.py
django/forms/forms.py
+1
-1
test_forms.py
tests/forms_tests/tests/test_forms.py
+18
-1
No files found.
django/forms/forms.py
Dosyayı görüntüle @
83a185a3
...
...
@@ -557,7 +557,7 @@ class BoundField(object):
name
=
self
.
html_name
else
:
name
=
self
.
html_initial_name
return
widget
.
render
(
name
,
self
.
value
(),
attrs
=
attrs
)
return
force_text
(
widget
.
render
(
name
,
self
.
value
(),
attrs
=
attrs
)
)
def
as_text
(
self
,
attrs
=
None
,
**
kwargs
):
"""
...
...
tests/forms_tests/tests/test_forms.py
Dosyayı görüntüle @
83a185a3
...
...
@@ -22,7 +22,9 @@ from django.template import Template, Context
from
django.test
import
TestCase
from
django.test.utils
import
str_prefix
from
django.utils.datastructures
import
MultiValueDict
,
MergeDict
from
django.utils.safestring
import
mark_safe
from
django.utils.encoding
import
force_text
from
django.utils.html
import
format_html
from
django.utils.safestring
import
mark_safe
,
SafeData
from
django.utils
import
six
...
...
@@ -1335,6 +1337,21 @@ class FormsTestCase(TestCase):
self
.
assertEqual
(
bound
[
'password'
]
.
value
(),
'foo'
)
self
.
assertEqual
(
unbound
[
'password'
]
.
value
(),
None
)
def
test_boundfield_rendering
(
self
):
"""
Python 2 issue: Test that rendering a BoundField with bytestring content
doesn't lose it's safe string status (#22950).
"""
class
CustomWidget
(
TextInput
):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
return
format_html
(
str
(
'<input{0} />'
),
' id=custom'
)
class
SampleForm
(
Form
):
name
=
CharField
(
widget
=
CustomWidget
)
f
=
SampleForm
(
data
=
{
'name'
:
'bar'
})
self
.
assertIsInstance
(
force_text
(
f
[
'name'
]),
SafeData
)
def
test_initial_datetime_values
(
self
):
now
=
datetime
.
datetime
.
now
()
# Nix microseconds (since they should be ignored). #22502
...
...
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