On 31.03.2016 01:08, Ryan Prater wrote:
Say I have a TypedMultipleChoiceField and I'm building a custom select
multiple widget in my template.
If I want to check a box based on an initial value (ie. default
checked options), OR check a box based on form data that has been
returned (ie. error state), I would do this:
<input type="checkbox" {% if form.field.value %}checked{% endif %}>
HOWEVER, {{form.field.value}} source documentation (boundfield.py)
states: "Returns the value for this BoundField, using the initial
value if the form is not bound or the data otherwise."
So basically the equivalent of:
return (form.field.data or form.field.initial)
Not really, since data that are falsey may be valid data. So it's not
equvalent to that.
*Wouldn't it be more appropriate and useful for boundfield.value to
return CLEANED data that has gone through to_python()? As in:*
return (form.field.*cleaned_data* or form.field.initial)
No because then you would lose non-cleaned data in case of errors.
Also there is no guarantee that cleaned up data is valid when re-evaluated.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/62a1b22e-3d8b-4241-bbf7-20145686ab33%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/62a1b22e-3d8b-4241-bbf7-20145686ab33%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" 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].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/56FD0C79.3080001%40gmail.com.
For more options, visit https://groups.google.com/d/optout.