mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-17 04:10:24 +00:00
Fix InheritanceManager when the model has a self reference.
Otherwise, we reach max recursion depth.
This commit is contained in:
parent
722246051a
commit
617ec2af01
2 changed files with 2 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue