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
dc63ad7a
Kaydet (Commit)
dc63ad7a
authored
Haz 12, 2017
tarafından
Maciej Jaworski
Kaydeden (comit)
Tim Graham
Haz 17, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28319 -- Made TextField with choices use a Select widget.
üst
3b050fd0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
__init__.py
django/db/models/fields/__init__.py
+3
-1
test_textfield.py
tests/model_fields/test_textfield.py
+6
-0
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
dc63ad7a
...
...
@@ -2109,7 +2109,9 @@ class TextField(Field):
# Passing max_length to forms.CharField means that the value's length
# will be validated twice. This is considered acceptable since we want
# the value in the form field (to pass into widget for example).
defaults
=
{
'max_length'
:
self
.
max_length
,
'widget'
:
forms
.
Textarea
}
defaults
=
{
'max_length'
:
self
.
max_length
}
if
not
self
.
choices
:
defaults
[
'widget'
]
=
forms
.
Textarea
defaults
.
update
(
kwargs
)
return
super
()
.
formfield
(
**
defaults
)
...
...
tests/model_fields/test_textfield.py
Dosyayı görüntüle @
dc63ad7a
from
unittest
import
skipIf
from
django
import
forms
from
django.db
import
connection
,
models
from
django.test
import
TestCase
...
...
@@ -18,6 +19,11 @@ class TextFieldTests(TestCase):
self
.
assertIsNone
(
tf1
.
formfield
()
.
max_length
)
self
.
assertEqual
(
2345
,
tf2
.
formfield
()
.
max_length
)
def
test_choices_generates_select_widget
(
self
):
"""A TextField with choices uses a Select widget."""
f
=
models
.
TextField
(
choices
=
[(
'A'
,
'A'
),
(
'B'
,
'B'
)])
self
.
assertIsInstance
(
f
.
formfield
()
.
widget
,
forms
.
Select
)
def
test_to_python
(
self
):
"""TextField.to_python() should return a string."""
f
=
models
.
TextField
()
...
...
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