Commit e091c18f authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

[py3] Removed a remaining use of __metaclass__.

parent 212a5129
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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):
+2 −7
Original line number Diff line number Diff line
@@ -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 ##############################################################