I have a real annoying issue with form.is_valid() always returning false on one of my forms, and this only happens when I manually define fields in a modelform, and in particular use ModelChoiceField and ModelMultipleChoiceFields passing in my own custom querysets
location = forms.ModelChoiceField(required=False, widget = forms.Select(), queryset = Location.objects.none())
I cannot find much in the way of good documentation about ModelForm.is_valid(), and essentially, if I don’t call it everything works fine. I am happy with this except for the fact that every Django forms example makes this call to is_valid().
So I guess my question is:
- Is it okay to not check if a form is valid?
- If it is not, any ideas why it is always returning false?
Thanks,
Mike
Try to find out the specific validation errors for your form, which will possibly give you more information about the specific error:
http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields