Opened 8 years ago
Last modified 8 years ago
#26970 closed Bug
disabled modelMultipleChoiceField does not validate anymore — at Initial Version
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
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
Note:
See TracTickets
for help on using tickets.