summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2010-03-31 08:08:29 +0000
committerBrian Rosner <brosner@gmail.com>2010-03-31 08:08:29 +0000
commit64e4ffc932c78e6ccd66f20d5d74083fda3a3915 (patch)
tree13639aeff75eedce36012eaec9734427b557c671 /django/forms
parent2613872969f52815859bad9533104b47b63d6375 (diff)
[1.1.X] Restored pre-r10062 behavior allowing None from formfield_callback to exclude itself from the form
Backported from r12891 from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12892 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 1b2bf372c5..959c34e31f 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -154,6 +154,7 @@ def fields_for_model(model, fields=None, exclude=None, formfield_callback=lambda
in the ``fields`` argument.
"""
field_list = []
+ ignored = []
opts = model._meta
for f in opts.fields + opts.many_to_many:
if not f.editable:
@@ -165,9 +166,14 @@ def fields_for_model(model, fields=None, exclude=None, formfield_callback=lambda
formfield = formfield_callback(f)
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):