If the issue is already resolved, ignore my update.
-- A little lengthy response, so that you can appreciate the full picture.
form-is_valid() is purely to do with the definition of the specific form - or rather the definition of the fields in the form. Because that is the only information known to Django. Now this form may come from a generic (unbound - that is not, linked to any database table) form or a form linked to a table. So you need to look at the definitions or validation as defined in the definition of the fields in the form or the underlying table. Some validations may be done by HTML itself (e.g. number) and the browser will catch them on its own. Whatever values are passed on by the browser to Django will first be validated (when you call form.is_valid()) as per the definitions / validations known to it.
Normally if is_valid() function returns False, the errors get attached to the respective fields and you need to show them. In the HTML associated with the form display, ensure that the field is shown as {{<field>}} in which case the error will also be automatically displayed. If you are displaying only the value, you might not realize what the error is.
I have a hunch that your field definition shows a field with 'required=True' but the field is not displayed. Or marked as 'disabled' or 'readonly'.
On Friday, August 23, 2019 at 1:26:56 AM UTC+5:30, Shubham Chauhan wrote:
On Friday, August 23, 2019 at 1:26:56 AM UTC+5:30, Shubham Chauhan wrote:
form.is_valid() is always return false please help
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ebea9e1e-b6cc-4390-9630-ca6676b89981%40googlegroups.com.
No comments:
Post a Comment