summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-08-14 23:44:46 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-14 23:45:12 +0200
commite091c18f50266097f648efc7cac2503968e9d217 (patch)
tree495183ee6fd7b45cc8bc21925eef61871536491e
parent212a5129842ffec9d42ae0dbdb55964fab2c5fa2 (diff)
[py3] Removed a remaining use of __metaclass__.
-rw-r--r--django/db/models/fields/subclassing.py5
-rw-r--r--django/forms/models.py9
2 files changed, 5 insertions, 9 deletions
diff --git a/django/db/models/fields/subclassing.py b/django/db/models/fields/subclassing.py
index d4d7d75222..e6153aefe0 100644
--- a/django/db/models/fields/subclassing.py
+++ b/django/db/models/fields/subclassing.py
@@ -2,8 +2,9 @@
Convenience routines for creating non-trivial Field subclasses, as well as
backwards compatibility utilities.
-Add SubfieldBase as the __metaclass__ for your Field subclass, implement
-to_python() and the other necessary methods and everything will work seamlessly.
+Add SubfieldBase as the metaclass for your Field subclass, implement
+to_python() and the other necessary methods and everything will work
+seamlessly.
"""
class SubfieldBase(type):
diff --git a/django/forms/models.py b/django/forms/models.py
index 0b07d31d9a..a40d31ad9f 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -401,13 +401,8 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
'formfield_callback': formfield_callback
}
- form_metaclass = ModelFormMetaclass
-
- # TODO: this doesn't work under Python 3.
- if issubclass(form, BaseModelForm) and hasattr(form, '__metaclass__'):
- form_metaclass = form.__metaclass__
-
- return form_metaclass(class_name, (form,), form_class_attrs)
+ # Instatiate type(form) in order to use the same metaclass as form.
+ return type(form)(class_name, (form,), form_class_attrs)
# ModelFormSets ##############################################################