Fix InheritanceManager when the model has a self reference.

Otherwise, we reach max recursion depth.
This commit is contained in:
Ryan Senkbeil 2014-02-19 15:28:01 -06:00
parent 722246051a
commit 617ec2af01
2 changed files with 2 additions and 0 deletions

View file

@ -106,6 +106,7 @@ class InheritanceQuerySetMixin(object):
rel for rel in model._meta.get_all_related_objects()
if isinstance(rel.field, OneToOneField)
and issubclass(rel.field.model, model)
and model is not rel.field.model
]
subclasses = []
if levels:

View file

@ -25,6 +25,7 @@ class InheritanceManagerTestParent(models.Model):
related = models.ForeignKey(
InheritanceManagerTestRelated, related_name="imtests", null=True)
normal_field = models.TextField()
related_self = models.OneToOneField("self", related_name="imtests_self", null=True)
objects = InheritanceManager()
def __unicode__(self):