#25980: Inconsistent error behaviour when providing a queryset as initial value 
on
ModelMultipleChoiceField
-------------------------------+--------------------
     Reporter:  karyon         |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.9
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 So i provided a queryset as initial value for a non-required and disabled
 ModelMultipleChoiceField. it seemed to work as i saw the correct values in
 the rendered output.

 but, when saving the form i got an error  {{{ Enter a list of values.}}}

 1. the error did not show up when the queryset i provided yielded no
 results, which is inconsistent. the reason for that is that
 
[https://github.com/django/django/blob/d91cc25a2a43cb2526943dc2285ffe59e38fabfd/django/forms/models.py#L1250
 this boolean expression] evaluates to true as soon as there are results in
 the queryset.

 2. something else appeared fishy to me: in one line this method returns a
 queryset ({{{self.queryset.none()}}}), but in the next line it raises an
 error if the value is neither a list nor a tuple.

 if you folks tell me what the intended behaviour is / which types should
 be used, i can try to create a fix if you want.

 3. and the last (slightly unrelated) issue: since the field was disabled,
 i was wondering why cleaning it doesn't take a shortcut and does nothing
 at all... bumped into this a few times.

--
Ticket URL: <https://code.djangoproject.com/ticket/25980>
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/049.19f3d459f4e5b8b71db602021f306654%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to