From e091c18f50266097f648efc7cac2503968e9d217 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 14 Aug 2012 23:44:46 +0200 Subject: [PATCH] [py3] Removed a remaining use of __metaclass__. --- django/db/models/fields/subclassing.py | 5 +++-- django/forms/models.py | 9 ++------- 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 ##############################################################