Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 075098f9fd06c42faaba01ec8f855f4d4e99dae6 1 parent 0d0cbfd
@malcolmt malcolmt authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 django/newforms/models.py
View
11 django/newforms/models.py
@@ -213,18 +213,19 @@ def __init__(self, options=None):
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:

0 comments on commit 075098f

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