Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 make it in some clean functions?

like image 842
robos85 Avatar asked Dec 13 '25 07:12

robos85


1 Answers

Just override the validation function with empty function

previousReportIdNotEqual=forms.MultipleChoiceField(required=False)

def empty(self):
    pass

previousReportIdNotEqual.validate=empty
like image 140
Ankur Bansal Avatar answered Dec 16 '25 01:12

Ankur Bansal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!