[Fixed]-Django how to override clean() method in a subclass of custom form?


You do it well, but you should load cleaned_data from super call like this:

class SubClassForm(MyCustomForm):
        # ... additional form fields here

    def clean(self):
        # Then call the clean() method of the super  class
        cleaned_data = super(SubClassForm, self).clean()
        # ... do some cross-fields validation for the subclass 

        # Finally, return the cleaned_data
        return cleaned_data

Leave a comment