Loading django/db/models/fields/subclassing.py +3 −2 Original line number Diff line number Diff line Loading @@ -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): Loading django/forms/models.py +2 −7 Original line number Diff line number Diff line Loading @@ -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 ############################################################## Loading Loading
django/db/models/fields/subclassing.py +3 −2 Original line number Diff line number Diff line Loading @@ -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): Loading
django/forms/models.py +2 −7 Original line number Diff line number Diff line Loading @@ -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 ############################################################## Loading