summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-27 08:05:59 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-27 08:05:59 +0000
commit7e9a22aae7a363a60d6aa2a27a06b1fd01d6ac13 (patch)
treec265d6a1d2cde8fde082be7f13a2d87bc369fdff
parentec8848dad50a4687a8bc3ba7270bf08dbf5ac25a (diff)
Fixed #7289 -- Made ModelForms behave like Forms in the sense that Field
objects don't appear as attributes on the final form instance. They continue to appear as elements of the form_instance.fields mapping. If you were relying on ModelForms having fields as attributes, then this will be slightly backwards incompatible. However, normal template usage will see no change at all. Patch from Daniel Pope. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8618 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/forms/models.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 677556d91b..cca5cae92c 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -163,6 +163,7 @@ class ModelFormMetaclass(type):
except NameError:
# We are defining ModelForm itself.
parents = None
+ declared_fields = get_declared_fields(bases, attrs, False)
new_class = super(ModelFormMetaclass, cls).__new__(cls, name, bases,
attrs)
if not parents:
@@ -170,7 +171,6 @@ class ModelFormMetaclass(type):
if 'media' not in attrs:
new_class.media = media_property(new_class)
- declared_fields = get_declared_fields(bases, attrs, False)
opts = new_class._meta = ModelFormOptions(getattr(new_class, 'Meta', None))
if opts.model:
# If a model is defined, extract form fields from it.