#26970: disabled modelMultipleChoiceField does not validate anymore
-------------------------------+--------------------------------------
Reporter: karyon | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
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
-------------------------------+--------------------------------------
Description changed by karyon:
Old description:
> i have the following test:
>
> {{{
> def test_foo(self):
> # Course has an m2m to degrees
> course = mommy.make(Course, semester=mommy.make(Semester),
> degrees=[mommy.make(Degree)])
>
> # get_form_data_from_instance creates a dict with all the
> attributes
> form_data = get_form_data_from_instance(ContributorCourseForm,
> course)
>
> form = ContributorCourseForm(form_data, instance=course)
> self.assertTrue(form.is_valid())
>
> # recreate form
> form = ContributorCourseForm(form_data, instance=course)
> # disable degrees field
> form.fields['degrees'].disabled = True
> self.assertTrue(form.is_valid())
> }}}
>
> the second assert fails. form.errors says "degrees: Enter a list of
> values." which doesn't make sense, since 1. it does have a degree (the
> form renders correctly with that degree selected), and 2. this shouldn't
> happen just because the field is disabled.
>
> this showed up in 3744fc1666c41aeb4ed44f31605bafdb413b42bc, the fix for
> https://code.djangoproject.com/ticket/26917#comment:1
New description:
i have the following test:
{{{
def test_foo(self):
# Course has an m2m to degrees
course = mommy.make(Course, semester=mommy.make(Semester),
degrees=[mommy.make(Degree)])
# get_form_data_from_instance creates a dict with all the
attributes
form_data = get_form_data_from_instance(ContributorCourseForm,
course)
# ContributorCourseForm is a simple ModelForm on Course
form = ContributorCourseForm(form_data, instance=course)
self.assertTrue(form.is_valid())
# recreate form
form = ContributorCourseForm(form_data, instance=course)
# disable degrees field
form.fields['degrees'].disabled = True
self.assertTrue(form.is_valid())
}}}
the second assert fails. form.errors says "degrees: Enter a list of
values." which doesn't make sense, since 1. it does have a degree (the
form renders correctly with that degree selected), and 2. this shouldn't
happen just because the field is disabled.
this showed up in 3744fc1666c41aeb4ed44f31605bafdb413b42bc, the fix for
https://code.djangoproject.com/ticket/26917#comment:1
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26970#comment:2>
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.0d9ba3132f64195dfcf19c1ebce517d1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.