Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 7e9a22aae7a363a60d6aa2a27a06b1fd01d6ac13 1 parent ec8848d
Malcolm Tredinnick authored August 27, 2008

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  django/forms/models.py
2  django/forms/models.py
@@ -163,6 +163,7 @@ def __new__(cls, name, bases, attrs):
163 163
         except NameError:
164 164
             # We are defining ModelForm itself.
165 165
             parents = None
  166
+        declared_fields = get_declared_fields(bases, attrs, False)
166 167
         new_class = super(ModelFormMetaclass, cls).__new__(cls, name, bases,
167 168
                 attrs)
168 169
         if not parents:
@@ -170,7 +171,6 @@ def __new__(cls, name, bases, attrs):
170 171
 
171 172
         if 'media' not in attrs:
172 173
             new_class.media = media_property(new_class)
173  
-        declared_fields = get_declared_fields(bases, attrs, False)
174 174
         opts = new_class._meta = ModelFormOptions(getattr(new_class, 'Meta', None))
175 175
         if opts.model:
176 176
             # If a model is defined, extract form fields from it.

0 notes on commit 7e9a22a

Please sign in to comment.
Something went wrong with that request. Please try again.