| 91 | def test_empty_queryset_return(self): |
| 92 | "If a model's ManyToManyField has blank=True and is saved with no data, a queryset is returned." |
| 93 | option = ChoiceOptionModel.objects.create(id=1, name='default') |
| 94 | form = ChoiceFieldForm({'multi_choice_optional': '', 'choice': option.id, 'choice_int': 1, |
| 95 | 'multi_choice': ['1'], 'multi_choice_int': [1]}) |
| 96 | self.assertEqual(form.is_valid(), True) |
| 97 | self.assertEqual(isinstance(form.cleaned_data['multi_choice_optional'], QuerySet), True) |
| 98 | # While we're at it, test whether a QuerySet is returned if there *is* a value. |
| 99 | self.assertEqual(isinstance(form.cleaned_data['multi_choice'], QuerySet), True) |
| 100 | |
120 | | </select><input type="hidden" name="initial-multi_choice_int" value="1" id="initial-id_multi_choice_int_0" /> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p>""") |
| 133 | </select><input type="hidden" name="initial-multi_choice_int" value="1" id="initial-id_multi_choice_int_0" /> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p> |
| 134 | <p><label for="id_multi_choice_optional">Multi choice optional:</label> <select multiple="multiple" name="multi_choice_optional" id="id_multi_choice_optional"> |
| 135 | <option value="1">ChoiceOption 1</option> |
| 136 | <option value="2">ChoiceOption 2</option> |
| 137 | <option value="3">ChoiceOption 3</option> |
| 138 | </select> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p>""") |
153 | | <input type="hidden" name="initial-multi_choice_int" value="3" id="initial-id_multi_choice_int_1" /> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p>""") |
| 171 | <input type="hidden" name="initial-multi_choice_int" value="3" id="initial-id_multi_choice_int_1" /> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p> |
| 172 | <p><label for="id_multi_choice_optional">Multi choice optional:</label> <select multiple="multiple" name="multi_choice_optional" id="id_multi_choice_optional"> |
| 173 | <option value="1">ChoiceOption 1</option> |
| 174 | <option value="2">ChoiceOption 2</option> |
| 175 | <option value="3">ChoiceOption 3</option> |
| 176 | </select> <span class="helptext"> Hold down "Control", or "Command" on a Mac, to select more than one.</span></p>""") |