[Answered ]-Django merge 2 querysets overide annotation

1👍

You can annotate the followers with an extra attribute that determines the username of that Influencer with:

from django.db.models import F

Follower.objects.filter(
    influencer__username__in=influencer_choosen_by_user
).annotate(
    influencer=F('influencer__username')
)

In that case the Follower objects will have an extra attribute .influencer which contains the username of the influencer. If a follower follows multiple influencers, the follower will occur twice or more in the queryset, each time with .influencer another username of the influencer_choosen_by_user.

Leave a comment