[Fixed]-Django – Form not valid but no error


You have not passed any data to the form, so it is not valid. The instance argument is not used to set the form data, just the initial data.


This is a humble attempt to provide a little background for Daniel Roseman’s answer above.

As you can see in the source, BaseForm.is_valid() does the following:

return self.is_bound and not self.errors

So, if is_valid() returns False, even though there are no errors, then is_bound must be False.

Now, the value for is_bound is assigned in BaseForm.__init__() (source):

self.is_bound = data is not None or files is not None

From the forms documentation:

A Form instance is either bound to a set of data, or unbound.

  • If it’s bound to a set of data, it’s capable of validating that data and rendering the form as HTML with the data displayed in the HTML.
  • If it’s unbound, it cannot do validation (because there’s no data to validate!), but it can still render the blank form as HTML.

Also note that errors is a property, which calls the full_clean() method (source), which does the actual validation.


Leave a comment