I have a “generic” InternForm that inherits from ModelForm and defines common messages, widgets, etc.
I defined a subclass called ApplyInternForm for application form that is accessible to everyone and I want to hide some of the “advanced” fields.
How can I override exclude setting in the form’s subclass?
class InternForm(ModelForm):
# ...
class Meta:
model = Intern
exclude = ()
class ApplyInternForm(InternForm):
def __init__(self, *args, **kwargs):
super(ApplyInternForm, self).__init__(*args, **kwargs)
self.Meta.exclude = ('is_active',) # this doesn't work
Defining a
Metaclass in the subclass worked for me: