diff options
| author | Brian Rosner <brosner@gmail.com> | 2010-03-31 07:43:52 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2010-03-31 07:43:52 +0000 |
| commit | e58c75fbdfbc2f11a1d3d6fd949f7375199c6663 (patch) | |
| tree | 283005df8a976963e373681697dd362b6f9042c6 /django/forms/models.py | |
| parent | 7bdb9a90d06a955d0ad099f9b72e6c2c30cb89dc (diff) | |
Restored pre-r10062 behavior allowing None from formfield_callback to exclude itself from the form
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12891 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/models.py')
| -rw-r--r-- | django/forms/models.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 608b87bd33..42de898aa7 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -167,6 +167,7 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None, formfield_c in the ``fields`` argument. """ field_list = [] + ignored = [] opts = model._meta for f in opts.fields + opts.many_to_many: if not f.editable: @@ -182,9 +183,14 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None, formfield_c formfield = formfield_callback(f, **kwargs) if formfield: field_list.append((f.name, formfield)) + else: + ignored.append(f.name) field_dict = SortedDict(field_list) if fields: - field_dict = SortedDict([(f, field_dict.get(f)) for f in fields if (not exclude) or (exclude and f not in exclude)]) + field_dict = SortedDict( + [(f, field_dict.get(f)) for f in fields + if ((not exclude) or (exclude and f not in exclude)) and (f not in ignored)] + ) return field_dict class ModelFormOptions(object): |
