Author: mtredinnick
Date: 2008-08-27 03:05:59 -0500 (Wed, 27 Aug 2008)
New Revision: 8618
Modified:
django/trunk/django/forms/models.py
Log:
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.
Modified: django/trunk/django/forms/models.py
===================================================================
--- django/trunk/django/forms/models.py 2008-08-27 07:27:09 UTC (rev 8617)
+++ django/trunk/django/forms/models.py 2008-08-27 08:05:59 UTC (rev 8618)
@@ -163,6 +163,7 @@
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 @@
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---