[py3] Removed a remaining use of __metaclass__.

This commit is contained in:
Aymeric Augustin 2012-08-14 23:44:46 +02:00
parent 212a512984
commit e091c18f50
2 changed files with 5 additions and 9 deletions

View File

@ -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 File

@ -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 ##############################################################