summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMaciej Jaworski <maciej.jaworski@tivix.com>2017-06-12 20:18:37 +0200
committerTim Graham <timograham@gmail.com>2017-06-17 08:23:32 -0400
commitdc63ad7ac09ef694f19ae1d7496367614889e6fd (patch)
tree1ee14846a870d76f5c03f61a27ce5d5e9785ee36 /django
parent3b050fd0d0b8dbf499bdb44ce12fa926298c0bd0 (diff)
Fixed #28319 -- Made TextField with choices use a Select widget.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 825440458e..260882bf5b 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -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)