Skip to content

After adding a mixin the from is not working. Error: "ModelForm has no model class specified." #29

@startmat

Description

@startmat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions