⬅︎ Back to Django ORM optimization story on selecting the least possible
See UPDATE above.
Try this: from django.contrib.postgres.aggregates import StringAgg from django.db.models import Func result = Song.objects.filter( artist=artist ).aggregate( names_hash=Func( StringAgg('name', ''), function='md5' ) )
Comment
See UPDATE above.
Parent comment
Try this: from django.contrib.postgres.aggregates import StringAgg from django.db.models import Func result = Song.objects.filter( artist=artist ).aggregate( names_hash=Func( StringAgg('name', ''), function='md5' ) )