Skip to content

Commit c984eea

Browse files
committed
Fix flaky test for GFK
1 parent f9f441c commit c984eea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/generic/models.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ class UnsupportedModel(models.Model):
287287

288288
class DummyGenericForeignKeyModel(models.Model):
289289
content_type = models.ForeignKey(
290-
contenttypes.ContentType, on_delete=models.CASCADE
290+
contenttypes.ContentType,
291+
on_delete=models.CASCADE,
292+
limit_choices_to={"model__in": ["person", "dog"]},
291293
)
292294
object_id = models.PositiveIntegerField()
293295
content_object = GenericForeignKey("content_type", "object_id")
@@ -297,7 +299,11 @@ class DummyGenericRelationModel(models.Model):
297299

298300
class GenericForeignKeyModelWithOptionalData(models.Model):
299301
content_type = models.ForeignKey(
300-
contenttypes.ContentType, on_delete=models.CASCADE, blank=True, null=True
302+
contenttypes.ContentType,
303+
on_delete=models.CASCADE,
304+
blank=True,
305+
null=True,
306+
limit_choices_to={"model__in": ["person", "dog"]},
301307
)
302308
object_id = models.PositiveIntegerField(blank=True, null=True)
303309
content_object = GenericForeignKey("content_type", "object_id")

0 commit comments

Comments
 (0)