diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-03-08 15:03:30 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-03-08 15:03:30 +0000 |
| commit | bae921dcff699b827cd423f01ed125221b32fc9a (patch) | |
| tree | 70978b4c50fce2f597ca0339438876e699db2287 /django | |
| parent | 5e3a2e2f3956f358b5e82e217c20bb0b36fb0665 (diff) | |
Fixed #11940 - ModelForm evaluates callable default values on form class creation
Thanks to Harm Geerts for the report and initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12721 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/__init__.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 9fe6dd3c54..898f73e614 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -445,9 +445,11 @@ class Field(object): "Returns a django.forms.Field instance for this database Field." defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} if self.has_default(): - defaults['initial'] = self.get_default() if callable(self.default): + defaults['initial'] = self.default defaults['show_hidden_initial'] = True + else: + defaults['initial'] = self.get_default() if self.choices: # Fields with choices get special treatment. include_blank = self.blank or not (self.has_default() or 'initial' in kwargs) |
