I'm trying to convert UUIDs to integers within an annotate.
So like:
Item.objects.values_list('pk', flat=True).annotate(
int_of_pk=int('pk')
)
which throws error:
ValueError: invalid literal for int() with base 10: 'pk'
or like:
from django.db.models import IntegerField
from django.db.models.functions import Cast
Item.objects.values_list('pk', flat=True).annotate(
int_of_pk=Cast('pk', output_field=IntegerField())
)
which throws error:
File "/path/ve/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.CannotCoerce: cannot cast type uuid to integer
LINE 1: ...em"."uuid", ("item"."uuid")::integer ...
^
Any ideas pop out at you?