i have a simple ModelForm:
class MyForm(ModelForm):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
d
As described in Creating forms from models - Selecting the fields to use, there are three ways:
editable=False. All forms created from the model will exclude the field.fields attribute in the Meta inner class to only include the fields you want.exclude attribute in the Meta inner class to list the fields you don't want.So if your model has fields field1, field2, and field3 and you don't want field3, technique #2 would look like this:
class MyModelForm(ModelForm):
class Meta:
model = MyModel
fields = ('field1', 'field2')
And technique #3 would look like this:
class MyModelForm(ModelForm):
class Meta:
model = MyModel
exclude = ('field3',)