summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-29 16:32:18 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-29 16:32:18 +0000
commitd0f5a58fbd73e1a9ccef405e16ac070787e98fd4 (patch)
treece29f623565f86138d038e64694b8355730f738c /django
parenta4ea8d4e939295178b593ebeaf15269b658e8a6a (diff)
Fixed #4653 -- Improved the logic to decide when to include (and select as
initial value) the blank choice for a model field with choices. Thanks to Ilya Semenov for persisting with this. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index b0dd55e3b9..ddf695816e 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -392,7 +392,7 @@ class Field(object):
"Returns a django.newforms.Field instance for this database Field."
defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
if self.choices:
- defaults['widget'] = forms.Select(choices=self.get_choices())
+ defaults['widget'] = forms.Select(choices=self.get_choices(include_blank=self.blank or not (self.has_default() or 'initial' in kwargs)))
if self.has_default():
defaults['initial'] = self.get_default()
defaults.update(kwargs)