I am trying to use array_agg() function of postgresql in django 1.8, but could not bump into a solution as of now. What I have come across is this. But the function is broken. Also no luck with using raw query, because we need to always include the primary key of the table and the field I want to use array_agg() is not the primary key. I am stuck. Any help will be appreciated.
Add a comment
|
1 Answer
The function has been added in django-dev.You can find it here.
class ArrayAgg(Aggregate):
function = 'ARRAY_AGG'
def convert_value(self, value, expression, connection, context):
if not value:
return []
return value
For now you can add ^ as custom class.