'Get comma separated id with Group by and annotate with sub-query in django

from django.db.models import Subquery, OuterRef

My queryset looks like this:

AssessmentQueueTable.objects.filter(patient=1,is_deleted=False).annotate(followup_id=
Subquery(FollowUp.objects.filter(reference_id=OuterRef('id')).values('id')[:1]))

from above query i get only one value in followup_id field like followup_id = 1,
but i need all comma separated id like followup_id = 1,2,3,4.
if i remove [:1] from sub-query it throws error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source