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
d91cc25a
Kaydet (Commit)
d91cc25a
authored
Ara 16, 2015
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25942 -- Fixed TypedChoiceField.has_changed with nullable field
This fixes a regression introduced by
87144036
.
üst
2ec23a3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
fields.py
django/forms/fields.py
+5
-6
1.9.1.txt
docs/releases/1.9.1.txt
+3
-0
test_fields.py
tests/forms_tests/tests/test_fields.py
+8
-0
No files found.
django/forms/fields.py
Dosyayı görüntüle @
d91cc25a
...
...
@@ -181,17 +181,16 @@ class Field(object):
"""
Return True if data differs from initial.
"""
# For purposes of seeing whether something has changed, None is
# the same as an empty string, if the data or initial value we get
# is None, replace it w/ ''.
initial_value
=
initial
if
initial
is
not
None
else
''
try
:
data
=
self
.
to_python
(
data
)
if
hasattr
(
self
,
'_coerce'
):
data
=
self
.
_coerce
(
data
)
initial_value
=
self
.
_coerce
(
initial_value
)
return
self
.
_coerce
(
data
)
!=
self
.
_coerce
(
initial
)
except
ValidationError
:
return
True
# For purposes of seeing whether something has changed, None is
# the same as an empty string, if the data or initial value we get
# is None, replace it with ''.
initial_value
=
initial
if
initial
is
not
None
else
''
data_value
=
data
if
data
is
not
None
else
''
return
initial_value
!=
data_value
...
...
docs/releases/1.9.1.txt
Dosyayı görüntüle @
d91cc25a
...
...
@@ -43,3 +43,6 @@ Bugfixes
* Fixed a state bug when using an ``AlterModelManagers`` operation
(:ticket:`25852`).
* Fixed ``TypedChoiceField`` change detection with nullable fields
(:ticket:`25942`).
tests/forms_tests/tests/test_fields.py
Dosyayı görüntüle @
d91cc25a
...
...
@@ -1246,6 +1246,14 @@ class FieldsTests(SimpleTestCase):
self
.
assertFalse
(
f
.
has_changed
(
1
,
'1'
))
self
.
assertFalse
(
f
.
has_changed
(
'1'
,
'1'
))
f
=
TypedChoiceField
(
choices
=
[(
''
,
'---------'
),
(
'a'
,
"a"
),
(
'b'
,
"b"
)],
coerce
=
six
.
text_type
,
required
=
False
,
initial
=
None
,
empty_value
=
None
,
)
self
.
assertFalse
(
f
.
has_changed
(
None
,
''
))
self
.
assertTrue
(
f
.
has_changed
(
''
,
'a'
))
self
.
assertFalse
(
f
.
has_changed
(
'a'
,
'a'
))
def
test_typedchoicefield_special_coerce
(
self
):
"""
Test a coerce function which results in a value not present in choices.
...
...
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