From c984eeabcd43c214ea6faede8aec4a84c2b24ba1 Mon Sep 17 00:00:00 2001 From: Rust Saiargaliev Date: Mon, 26 Aug 2024 08:57:34 +0200 Subject: [PATCH] Fix flaky test for GFK --- tests/generic/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/generic/models.py b/tests/generic/models.py index 1930bcdb..1e98ed41 100755 --- a/tests/generic/models.py +++ b/tests/generic/models.py @@ -287,7 +287,9 @@ class UnsupportedModel(models.Model): class DummyGenericForeignKeyModel(models.Model): content_type = models.ForeignKey( - contenttypes.ContentType, on_delete=models.CASCADE + contenttypes.ContentType, + on_delete=models.CASCADE, + limit_choices_to={"model__in": ["person", "dog"]}, ) object_id = models.PositiveIntegerField() content_object = GenericForeignKey("content_type", "object_id") @@ -297,7 +299,11 @@ class DummyGenericRelationModel(models.Model): class GenericForeignKeyModelWithOptionalData(models.Model): content_type = models.ForeignKey( - contenttypes.ContentType, on_delete=models.CASCADE, blank=True, null=True + contenttypes.ContentType, + on_delete=models.CASCADE, + blank=True, + null=True, + limit_choices_to={"model__in": ["person", "dog"]}, ) object_id = models.PositiveIntegerField(blank=True, null=True) content_object = GenericForeignKey("content_type", "object_id")