[I posted a usage question on the same subject to django-users a short
time ago, and Karen suggested I bring the issue here.]

Since rev 10206, if a form in a formset has validation errors but is
marked for deletion, the formset is_valid returns True (assuming there
are no other form errors).  Prior to rev 10206 it would return False.
The change was on the grounds that "formset with can_delete shouldn't
require deleted forms to
validate" -- see ticket #9587 [1].

I understand the thinking behind the change, but I think I've hit an
unintended consequence: it's no longer possible (straightforwardly) to
use the validation mechanism to prevent the deletion.

My application behaviour (which worked pre-10206 but doesn't work from
10206) is as follows:  There's a formset, with delete checkboxes and
some other fields in each form.  The user may wish to delete some rows
(forms).  On submit, the application decides whether the deletion(s)
can go ahead, based on some dynamic state.  If any deletions are not
allowed, the user is presented with error messages alongside each form
explaining why not.  This is implemented by having a clean() method on
the form that checked for cleaned_data['DELETE'], performed the check,
and if necessary raised a ValidationError with an error message along
the lines of "You cannot delete this right now because ...".

Prior to 10206, the formset is_valid returned False and the user saw
the error messages as I intended.  From 10206 on, the formset is_valid
returns True (because validation errors on forms marked for deletion
"don't count") and so my view goes on to try to save the forms.

So, is this an unintended consequence?  If so, please can it be backed
out pending further design discussion?

Regards

Dan

[1] http://code.djangoproject.com/ticket/9587

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to