I am trying to use django-cte on models managed with reversion. When running createinitialrevisions, it seems that the correct QuerySet or manager is not used:
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/reversion/management/commands/createinitialrevisions.py", line 66, in handle
live_objs = _safe_subquery(
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/reversion/models.py", line 389, in _safe_subquery
left_query = left_query.annotate(**{exist_annotation_name: models.Exists(right_subquery)})
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/django/db/models/query.py", line 1091, in annotate
return self._annotate(args, kwargs, select=True)
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/django/db/models/query.py", line 1130, in _annotate
clone.query.add_annotation(
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/django_cte/query.py", line 49, in add_annotation
super(CTEQuery, self).add_annotation(annotation, *args, **kw)
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1039, in add_annotation
annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None,
File "/home/lukas/.cache/pypoetry/virtualenvs/aleksis-core-yiBKpV3N-py3.10/lib/python3.10/site-packages/django_cte/expressions.py", line 45, in resolve_expression
for cte in get_query(clone)._with_ctes:
AttributeError: 'Query' object has no attribute '_with_ctes'
I cannot really wrap my head around it; apart from running the management command, everything works fine.
Maybe someone who knows about how django-cte uses custom QuerySets can help understand the issue?
I am trying to use django-cte on models managed with reversion. When running
createinitialrevisions
, it seems that the correctQuerySet
or manager is not used:I cannot really wrap my head around it; apart from running the management command, everything works fine.
Maybe someone who knows about how django-cte uses custom QuerySets can help understand the issue?