Reputation: 4504
I have a ModelForm with several fields. Some of them should not be checked when I call form.is_valid(). However, I still want them displayed in the template so I don't think I can exclude them from the form. Is there a way to overload form.is_valid() to loop through all the fields and only actually validate the ones I care about?
Upvotes: 1
Views: 1112
Reputation: 1
If you mean that you wish to allow blank fields then you can specify blank=True
in the the model's class definition.
eg:
screen_name = models.CharField(max_length=25, null=True, blank=True)
Upvotes: 0
Reputation: 238
A quick solution without any other research is it overwrite the field's clean method to essentially check nothing. That way when clean is called for that field, validation will pass.
Upvotes: 3