Fixed #27563 -- Moved "apply limit_choices_to" code from BaseModelForm to fields_for_model().

This commit is contained in:
Jon Dufresne 2016-12-01 18:28:29 -08:00
parent 6d1394182d
commit 6abd6c598e
2 changed files with 9 additions and 7 deletions

View file

@ -2854,6 +2854,10 @@ class LimitChoicesToTest(TestCase):
f = StumpJokeWithCustomFieldForm()
self.assertEqual(f.fields['custom'].queryset, 42)
def test_fields_for_model_applies_limit_choices_to(self):
fields = fields_for_model(StumpJoke, ['has_fooled_today'])
self.assertSequenceEqual(fields['has_fooled_today'].queryset, [self.threepwood])
class FormFieldCallbackTests(SimpleTestCase):