#25980: Wrong handling of initial value on disabled ModelMultipleChoiceField
-------------------------------+--------------------------------------
Reporter: karyon | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by karyon):
if inconsistent behaviour on incorrect input is acceptable, i agree that
django is doing nothing wrong.
however, i think that the current situation isn't very user friendly.
basically, i can provide a queryset as initial value and that is fine as
long as i don't disable the field. if i want to disable the field, i
necessarily need to apply a {{{values_list('pk', flat=True)}}} to the
initial value. which seems unnecessary, especially since the field outputs
a queryset, so why shouldn't the input be a queryset as well? afaics most
other fields can deal with their output data format as input.
on a related note,
https://docs.djangoproject.com/en/1.9/ref/forms/fields/#django.forms.Field.initial
says "initial values are not used as “fallback” data in validation.
initial values are only intended for initial form display". why is the
initial value validated/cleaned at all? skipping cleaning on disabled
fields would solve this as well. is that possible or is the result of
cleaning still needed on disabled fields?
so i'd vote for
1. skipping validation on disabled fields if possible
2. make ModelMultipleChoiceFields deal with querysets as initial values
3. or clarify in the docs that initial values must be pks and one has to
use values_list('pk', flat=True).
--
Ticket URL: <https://code.djangoproject.com/ticket/25980#comment:9>
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/064.4a74dd8dcc0e8efebc89fe74b97ccf33%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.