django - disable field validaton in form
I need to disable field validation in ModelForm. I want this validation not to validate some field. I have some situations (AJAX rendering form) when I want to return more complex form with additional fields. I pass POST to the form and render new one with post fields saved. Some new fields are added and they can't be validated. I pass flag to form and recognize when it happens. Should I ma开发者_如何转开发ke it in some clean functions?
Just override the validation function with empty function
previousReportIdNotEqual=forms.MultipleChoiceField(required=False)
def empty(self):
pass
previousReportIdNotEqual.validate=empty
If the model field has blank=True, then required is set to False on the form field. Otherwise, required=True.
精彩评论