#7018: Make ModelForm multiple inheritance is possible.
--------------------------------------+-------------------------------------
Reporter: bear330 | Owner: nobody
Status: new | Milestone: post-1.0
Component: django.newforms | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Comment (by bear330):
After [7846], that this way to make ModelForm be able to multiple
inheritance is invalid.
New way to make it work is:
{{{
def getMixupFormMetaClass():
"""
Get metaclass for form class that inherits multiple forms, especially
the
base classes of form mix up with Form and ModelForm (metaclass mix up
with
DeclarativeFieldsMetaclass, ModelFormMetaclass).
See http://code.djangoproject.com/ticket/7018 for related details.
@return Function that will generate class that metaclass will do.
"""
from django.newforms import models as nmodels
factory = classmaker()
def new(name, bases, attrs):
# get_declared_fields can only be called once, the result will be
wrong
# if you call it again. We call it first to hold the correct
result.
fields = nmodels.get_declared_fields(bases, attrs, True)
newclass = factory(name, bases, attrs)
# Restore the correct result.
newclass.base_fields = fields
return newclass
return new
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/7018#comment:4>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---