Friday, August 23, 2019

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

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/67c7dae2-1954-4403-a9cb-ccc7bb831ecb%40googlegroups.com.

No comments:

Post a Comment