diff options
Diffstat (limited to 'tests/model_forms/tests.py')
| -rw-r--r-- | tests/model_forms/tests.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 9931fa50e3..7907aa1c3d 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -21,10 +21,10 @@ from django.test.utils import isolate_apps from .models import ( Article, ArticleStatus, Author, Author1, Award, BetterWriter, BigInt, Book, Category, Character, Colour, ColourfulItem, CustomErrorMessage, CustomFF, - CustomFieldForExclusionModel, DateTimePost, DerivedBook, DerivedPost, + CustomFieldForExclusionModel, DateTimePost, DerivedBook, DerivedPost, Dice, Document, ExplicitPK, FilePathModel, FlexibleDatePost, Homepage, ImprovedArticle, ImprovedArticleWithParentLink, Inventory, - NullableUniqueCharFieldModel, Person, Photo, Post, Price, Product, + NullableUniqueCharFieldModel, Number, Person, Photo, Post, Price, Product, Publication, PublicationDefaults, StrictAssignmentAll, StrictAssignmentFieldSpecific, Student, StumpJoke, TextFile, Triple, Writer, WriterProfile, test_images, @@ -2896,6 +2896,19 @@ class LimitChoicesToTests(TestCase): [self.marley, self.threepwood], ) + def test_limit_choices_to_m2m_through(self): + class DiceForm(forms.ModelForm): + class Meta: + model = Dice + fields = ['numbers'] + + Number.objects.create(value=0) + n1 = Number.objects.create(value=1) + n2 = Number.objects.create(value=2) + + form = DiceForm() + self.assertCountEqual(form.fields['numbers'].queryset, [n1, n2]) + class FormFieldCallbackTests(SimpleTestCase): |
