我有一个“通用” InternForm
,它继承ModelForm
并定义了常见的消息、小部件等。
ApplyInternForm
我为每个人都可以访问的申请表定义了一个子类,我想隐藏一些“高级”字段。
如何覆盖exclude
表单子类中的设置?
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