Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Removed a remaining use of __metaclass__.

  • Loading branch information...
commit e091c18f50266097f648efc7cac2503968e9d217 1 parent 212a512
@aaugustin aaugustin authored
View
5 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):
View
9 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 ##############################################################
Please sign in to comment.
Something went wrong with that request. Please try again.