Skip to content

Commit

Permalink
Fix Subquery support for Django <3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch authored and Suor committed Sep 26, 2020
1 parent da92389 commit 1aac489
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cacheops/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def table_for(alias):
# Add any subqueries used for annotation
if qs.query.annotations:
subqueries = (
query_dnf(q.query) for q in qs.query.annotations.values() if type(q) is Subquery
# Django 3.0+ sets Subquery.query
query_dnf(getattr(q, 'query', q.queryset.query)) for q in qs.query.annotations.values()
if type(q) is Subquery
)
dnfs_.update(join_with(lcat, subqueries))

Expand Down

0 comments on commit 1aac489

Please sign in to comment.