Adding a simple mixin to a ModelForm is not possible since the Meta is "overwritten" by the EntangledFormMetaclass. This is the unittest to proove. Just add at the end of tests/test_inheritance.py
class BasicFormMixin():
test_attr = "Hello"
def test_method(self):
return self.test_attr + " World"
class FormMixinTest(BasicFormMixin, ProductForm):
""" New class with mixin"""
@pytest.mark.django_db
def test_form_mixin():
# check if .Meta is handled correctly
assert hasattr(FormMixinTest.Meta, 'model')
assert FormMixinTest.Meta.model == Product
Do I miss something ?
Thank you for you effort, greetings from Vienna.
br
Matthias