If I have 3 fields in my Form class and in fields
I set only one field, on my html page still will be 3 fields.
Example:
class CategoryForm(forms.ModelForm):
name = forms.CharField(max_length=128,
help_text='Please enter the category name.')
views = forms.IntegerField(initial=0)
likes = forms.IntegerField(initial=0)
slug = forms.CharField(widget=forms.HiddenInput(), initial=0)
class Meta:
model = Category
fields = ('name',)
So fields
variable doesn't hide anything?
"The generated Form class will have a form field for every model field specified, in the order specified in the fields attribute."
If you want to hide fields, use
I highly recommend you to take a look at the docs:
https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#selecting-the-fields-to-use