1) You can define the second version of the form:
class MyExcludedModelForm(MyModelForm):
class Meta:
excludes = ('my_bool',)
2) You can overwrite the form constructor:
(same as described in another SO post that you are referencing)
class MyModelForm(ModelForm):
def __init__(self, *args, **kwargs):
if not kwargs.get('enable_my_bool', false):
self.fields.pop('my_bool')
super(MyModelForm, self).__init__(*args, **kwargs)
source
share