Call annotate after union will raise error, why, how can I solve it?

40 views
Skip to first unread message

Louie Feng

unread,
Aug 23, 2019, 7:19:35 AM8/23/19
to Django users
Call annotate after union will raise error, why, how can I solve it?
For example:

cards = card10.union(SCPSimcard.objects.filter(pk=7))
cards.annotate(n=F('id'))

the follow is traceback info:
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\hasee\Envs\tb_simcard\lib\site-packages\django\db\models\query.py", line 250, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "C:\Users\hasee\Envs\tb_simcard\lib\site-packages\django\db\models\query.py", line 274, in __iter__
    self._fetch_all()
  File "C:\Users\hasee\Envs\tb_simcard\lib\site-packages\django\db\models\query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "C:\Users\hasee\Envs\tb_simcard\lib\site-packages\django\db\models\query.py", line 78, in __iter__
    setattr(obj, attr_name, row[col_pos])
IndexError: list index out of range
Reply all
Reply to author
Forward
0 new messages