[Fixed]-Subclassing Django ModelForms


This is a late answer, but I wanted to note that you can subclass the inner Meta class like this:

class SocialForm(BasicForm):
    class Meta(BasicForm.Meta):
        fields = BasicForm.Meta.fields + ('facebook', 'twitter')

That way you don’t have to repeat the model = Business definition, and any other Meta attributes you may add to BasicForm will automatically be inherited by SocialForm.

For reference, here’s the Django documentation on this approach.

Leave a comment