Opened 8 years ago
Last modified 8 years ago
#26970 closed Bug
Disabled ModelMultipleChoiceField does not validate anymore — at Version 3
Reported by: | karyon | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.10 |
Severity: | Release blocker | Keywords: | |
Cc: | johannes.linke@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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
likely related: https://code.djangoproject.com/ticket/25980, same error message when providing a queryset as initial value to a disabled ModelMultipleChoiceField.
Change History (3)
comment:1 by , 8 years ago
Cc: | added |
---|
comment:2 by , 8 years ago
Description: | modified (diff) |
---|
comment:3 by , 8 years ago
Description: | modified (diff) |
---|---|
Summary: | disabled modelMultipleChoiceField does not validate anymore → Disabled ModelMultipleChoiceField does not validate anymore |