Kaydet (Commit) 075098f9 authored tarafından Malcolm Tredinnick's avatar Malcolm Tredinnick

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
üst 0d0cbfd5
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment