#27148: Invalid input for UUIDField with ModelMultipleChoiceField throws
ValueError, not ValidationError
----------------------------+--------------------
     Reporter:  blueyed     |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Forms       |    Version:  1.10
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 I have added a test in https://github.com/django/django/pull/7180.

 This test shows that an invalid value for a UUIDField will bubble up as
 `ValueError`.  The problem here seems to be that `get_prep_value` just
 passes through the (invalid) string.

 Only when the queryset is evaluated just below via the following code,
 the ValueError from `UUIDField.get_db_prep_value` is raised and bubbles
 up:

 {{{
 self.queryset.filter(**{'%s__in' % key: value})
 pks = set(force_text(getattr(o, key)) for o in qs)
 }}}

 Explicitly evaluating the queryset above already would fix it, but that
 would get done for every selected value then.

 Needs `UUIDField` to be fixed for this, e.g. raising the `ValueError`
 from `get_prep_value` already?
 In this case other fields would need the same fix probably (from what I
 have seen while skimming the code).

--
Ticket URL: <https://code.djangoproject.com/ticket/27148>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.4671886a934d7a4bba44572fec556ad9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to