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
09da1e79
Kaydet (Commit)
09da1e79
authored
Kas 06, 2016
tarafından
Michal Petrucha
Kaydeden (comit)
Tim Graham
Kas 06, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27369 -- Prevented widgets from being shared between form field instances.
üst
37809b89
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
fields.py
django/forms/fields.py
+2
-0
test_base.py
tests/forms_tests/field_tests/test_base.py
+15
-1
tests.py
tests/model_forms/tests.py
+1
-1
No files found.
django/forms/fields.py
Dosyayı görüntüle @
09da1e79
...
...
@@ -94,6 +94,8 @@ class Field(object):
widget
=
widget
or
self
.
widget
if
isinstance
(
widget
,
type
):
widget
=
widget
()
else
:
widget
=
copy
.
deepcopy
(
widget
)
# Trigger the localization machinery if needed.
self
.
localize
=
localize
...
...
tests/forms_tests/field_tests/test_base.py
Dosyayı görüntüle @
09da1e79
from
django.forms
import
Field
from
django.forms
import
ChoiceField
,
Field
,
Form
,
Select
from
django.test
import
SimpleTestCase
...
...
@@ -20,3 +20,17 @@ class BasicFieldsTests(SimpleTestCase):
f
=
ComplexField
()
self
.
assertTrue
(
f
.
class_a_var
)
def
test_field_deepcopies_widget_instance
(
self
):
class
CustomChoiceField
(
ChoiceField
):
widget
=
Select
(
attrs
=
{
'class'
:
'my-custom-class'
})
class
TestForm
(
Form
):
field1
=
CustomChoiceField
(
choices
=
[])
field2
=
CustomChoiceField
(
choices
=
[])
f
=
TestForm
()
f
.
fields
[
'field1'
]
.
choices
=
[(
'1'
,
'1'
)]
f
.
fields
[
'field2'
]
.
choices
=
[(
'2'
,
'2'
)]
self
.
assertEqual
(
f
.
fields
[
'field1'
]
.
widget
.
choices
,
[(
'1'
,
'1'
)])
self
.
assertEqual
(
f
.
fields
[
'field2'
]
.
widget
.
choices
,
[(
'2'
,
'2'
)])
tests/model_forms/tests.py
Dosyayı görüntüle @
09da1e79
...
...
@@ -2867,7 +2867,7 @@ class FormFieldCallbackTests(SimpleTestCase):
fields
=
"__all__"
Form
=
modelform_factory
(
Person
,
form
=
BaseForm
)
self
.
assertIs
(
Form
.
base_fields
[
'name'
]
.
widget
,
widget
)
self
.
assertIs
Instance
(
Form
.
base_fields
[
'name'
]
.
widget
,
forms
.
Textarea
)
def
test_factory_with_widget_argument
(
self
):
""" Regression for #15315: modelform_factory should accept widgets
...
...
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