Changed ModelFormMetaclass to have the normal signature for a __new__ method.
Allows extending the metaclass more normally. Patch from Christian Tanzer. Refs #7617. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7847 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0d0cbfd56e
commit
075098f9fd
|
@ -213,18 +213,19 @@ class ModelFormOptions(object):
|
|||
|
||||
|
||||
class ModelFormMetaclass(type):
|
||||
def __new__(cls, name, bases, attrs,
|
||||
formfield_callback=lambda f: f.formfield()):
|
||||
def __new__(cls, name, bases, attrs):
|
||||
formfield_callback = attrs.pop('formfield_callback',
|
||||
lambda f: f.formfield())
|
||||
try:
|
||||
parents = [b for b in bases if issubclass(b, ModelForm)]
|
||||
except NameError:
|
||||
# We are defining ModelForm itself.
|
||||
parents = None
|
||||
new_class = super(ModelFormMetaclass, cls).__new__(cls, name, bases,
|
||||
attrs)
|
||||
if not parents:
|
||||
return super(ModelFormMetaclass, cls).__new__(cls, name, bases,
|
||||
attrs)
|
||||
return new_class
|
||||
|
||||
new_class = type.__new__(cls, name, bases, attrs)
|
||||
declared_fields = get_declared_fields(bases, attrs, False)
|
||||
opts = new_class._meta = ModelFormOptions(getattr(new_class, 'Meta', None))
|
||||
if opts.model:
|
||||
|
|
Loading…
Reference in New Issue