Skip to content

Commit

Permalink
Keep track of whether or not we could yield root nodes. Should allow …
Browse files Browse the repository at this point in the history
…me to raise an error only when passing in models(None) and it was previously set to False.
  • Loading branch information
kezabelle committed Jun 22, 2016
1 parent 455a65c commit a5cdb1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions inheritrix.py
Expand Up @@ -127,10 +127,12 @@ class InheritingQuerySet(QuerySet):
def __init__(self, *args, **kwargs):
super(InheritingQuerySet, self).__init__(*args, **kwargs)
self._our_joins = []
self._include_self = True

def _clone(self, *args, **kwargs):
clone = super(InheritingQuerySet, self)._clone(*args, **kwargs)
clone._our_joins = self._our_joins[:]
clone._include_self = self._include_self
return clone

def select_subclasses(self, *subclasses):
Expand Down Expand Up @@ -170,6 +172,7 @@ def models(self, *models, **options):
if 'include_self' not in options or options['include_self'] is not True:
x = generate_q_filters(lookups=all_combinations)
clone.query.add_q(x)
clone._include_self = False
return clone

def iterator(self):
Expand Down

0 comments on commit a5cdb1a

Please sign in to comment.