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
216bb2e8
Kaydet (Commit)
216bb2e8
authored
Mar 22, 2017
tarafından
James Beith
Kaydeden (comit)
Tim Graham
Mar 22, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27975 -- Fixed crash if ModelChoiceField's queryset=None.
Regression in 9153d8fbd6385db9f48793662de789fc3d686841.
üst
325db2a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
models.py
django/forms/models.py
+2
-1
tests.py
tests/model_forms/tests.py
+11
-0
No files found.
django/forms/models.py
Dosyayı görüntüle @
216bb2e8
...
@@ -1155,7 +1155,8 @@ class ModelChoiceField(ChoiceField):
...
@@ -1155,7 +1155,8 @@ class ModelChoiceField(ChoiceField):
def
__deepcopy__
(
self
,
memo
):
def
__deepcopy__
(
self
,
memo
):
result
=
super
(
ChoiceField
,
self
)
.
__deepcopy__
(
memo
)
result
=
super
(
ChoiceField
,
self
)
.
__deepcopy__
(
memo
)
# Need to force a new ModelChoiceIterator to be created, bug #11183
# Need to force a new ModelChoiceIterator to be created, bug #11183
result
.
queryset
=
self
.
queryset
.
all
()
if
self
.
queryset
is
not
None
:
result
.
queryset
=
self
.
queryset
.
all
()
return
result
return
result
def
_get_queryset
(
self
):
def
_get_queryset
(
self
):
...
...
tests/model_forms/tests.py
Dosyayı görüntüle @
216bb2e8
...
@@ -1640,6 +1640,17 @@ class ModelChoiceFieldTests(TestCase):
...
@@ -1640,6 +1640,17 @@ class ModelChoiceFieldTests(TestCase):
form2
=
ModelChoiceForm
()
form2
=
ModelChoiceForm
()
self
.
assertIsNone
(
form2
.
fields
[
'category'
]
.
queryset
.
_result_cache
)
self
.
assertIsNone
(
form2
.
fields
[
'category'
]
.
queryset
.
_result_cache
)
def
test_modelchoicefield_queryset_none
(
self
):
class
ModelChoiceForm
(
forms
.
Form
):
category
=
forms
.
ModelChoiceField
(
queryset
=
None
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
ModelChoiceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'category'
]
.
queryset
=
Category
.
objects
.
filter
(
slug__contains
=
'test'
)
form
=
ModelChoiceForm
()
self
.
assertCountEqual
(
form
.
fields
[
'category'
]
.
queryset
,
[
self
.
c2
,
self
.
c3
])
def
test_modelchoicefield_22745
(
self
):
def
test_modelchoicefield_22745
(
self
):
"""
"""
#22745 -- Make sure that ModelChoiceField with RadioSelect widget
#22745 -- Make sure that ModelChoiceField with RadioSelect widget
...
...
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