1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #25040 -- Fixed migrations state crash with GenericForeignKey

This commit is contained in:
Kai Richard Koenig
2015-07-01 09:21:17 +02:00
committed by Tim Graham
parent 11cac1bd8e
commit 60f795c060
2 changed files with 8 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
from django.apps.registry import Apps
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models
from django.db.migrations.exceptions import InvalidBasesError
from django.db.migrations.operations import (
@@ -1049,6 +1050,12 @@ class RelatedModelsTests(SimpleTestCase):
self.assertRelated(S, [A, B, T])
self.assertRelated(T, [A, B, S])
def test_generic_fk(self):
A = self.create_model("A", foreign_keys=[models.ForeignKey('B'), GenericForeignKey()])
B = self.create_model("B", foreign_keys=[models.ForeignKey('C')])
self.assertRelated(A, [B])
self.assertRelated(B, [A])
def test_abstract_base(self):
A = self.create_model("A", abstract=True)
B = self.create_model("B", bases=(A,))