ModelMultipleChoiceField ignore invalid choices?

61 views
Skip to first unread message

Jon Dufresne

unread,
Oct 7, 2013, 12:15:43 PM10/7/13
to django...@googlegroups.com
Hi,

I am using a ModelForm with a ModelMultipleChoiceField. I would like
for this field to silently ignore invalid choices instead of creating
a form error. Here is my use case:

* User A opens form select model choice 1, 2, and 3
* User B (different browser) deletes model choice 3 entirely from system
* User A submits form and receives error

I understand why this should be an error in the general case, but in
my case, I want this to silently ignore the invalid choice 3 and
continue with choice 1 and 2? Is this possible?

Thanks,
Jon

David Cox

unread,
Oct 9, 2013, 10:08:43 AM10/9/13
to django...@googlegroups.com
This could be handled in the form clean() and/or save() methods using a try/catch block and passing on thrown exceptions.  You'd have to figure out what would be an acceptable way to handle a form submission with an invalid selection, though.
Reply all
Reply to author
Forward
0 new messages