Django assumes that all input data in forms can be validated by `Form.is_valid()` which in some cases is not true. Database contraints, e.g. unique, can fail even though they are checked. An application may require communication with other servers while processing data which can lead to errors. But these conditions are not expected by regular Django form flow and an attempt to handle these cases results in large overriding of default implementation.
This topic was previously discussed here https://groups.google.com/d/topic/django-developers/rzjpP0byNQo/discussion, but discussion was mainly based on race condition in unique check. I'd like to reopen the topic because there are other possibilities which may cause the possibility of failure after form validation to become real, especially if network connection is involved.
I suggest Django should provide mechanism which allow handling the unexpected failures after form validation, e.g. expect `ValidationError` to be raised by `ModelAdmin.save_model`.
I started this discussion as a result of wontfix from https://code.djangoproject.com/ticket/25777.
Vlastik
I'm also in favor of some solution here. I used to raise a ValidationError with either a particular field if I was able to extract the particular error via regex matches, or as non_field_errors. That was my best I had instead of resulting in a 5xx. In most cases for example a unique race condition, when the user will resubmit the form it will have the detailed validation errors or pass.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/1db10ddc-eae6-4f17-a596-b8ce1aa8ef1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.