Skip to content

Commit c035954

Browse files
committed
Simplify the get_queryst() / get_query_set() call choice
1 parent 2c3ff97 commit c035954

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

polymorphic_tree/managers.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
The manager class for the CMS models
33
"""
4-
import django
54
from mptt.managers import TreeManager
65
from polymorphic import PolymorphicManager
76
from polymorphic.query import PolymorphicQuerySet
@@ -30,11 +29,6 @@ def toplevel(self):
3029
"""
3130
Return all nodes which have no parent.
3231
"""
33-
if hasattr(PolymorphicManager, 'get_queryset') and django.VERSION >= (1,6):
34-
# Latest django-polymorphic for Django 1.7
35-
# Should not be used for Django 1.4/1.5 all all, as that breaks the RelatedManager
36-
qs = self.get_queryset()
37-
else:
38-
qs = self.get_query_set()
39-
40-
return qs.toplevel()
32+
# By using .all(), the proper get_query_set()/get_queryset() will be used for each Django version.
33+
# Django 1.4/1.5 need to use get_query_set(), because the RelatedManager overrides that.
34+
return qs.all().toplevel()

0 commit comments

Comments
 (0)