Hoping I could annotate a QuerySet with an array aggregate, I tried the following:
Item.objets.annotate(
results=ArrayAgg(
RawSQL("row(field_a, field_b)", []),
output_field=ArrayField(ArrayField(models.IntegerField())))
)
)
And it basically works except that – unless I'm returning a 1-dimensional array – I only get strings of PostgreSQL's array representations as a return value:
'{"(30,8686)"}' instead of [(30,8686)]
Does anyone have an Idea how to get proper Python lists that I can iterate through in the template?