Skip to content

Commit

Permalink
Merge pull request #114 from rsenkbeil/inheritance-manager-self-refer…
Browse files Browse the repository at this point in the history
…ence

Fix InheritanceManager when the model has a self reference.
  • Loading branch information
carljm committed Feb 19, 2014
2 parents fe0ecea + 617ec2a commit f26b33a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _get_subclasses_recurse(self, model, levels=None):
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:
Expand Down
1 change: 1 addition & 0 deletions model_utils/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f26b33a

Please sign in to comment.