def get_occupied_streams(realm):
 subs_filter = Subscription.objects.filter(active=True, user_profile__realm=realm, user_profile__is_active=True).values('recipient_id')
 stream_ids = Recipient.objects.filter(type=Recipient.STREAM, id__in=subs_filter).values('type_id')
 return Stream.objects.filter(id__in=stream_ids, realm=realm, deactivated=False)

def get_occupied_streams ( realm ) : subs_filter = Subscription . objects . filter ( active = True , user_profile__realm = realm , user_profile__is_active = True ) . values ( 'recipient_id' ) stream_ids = Recipient . objects . filter ( type = Recipient . STREAM , id__in = subs_filter ) . values ( 'type_id' ) return Stream . objects . filter ( id__in = stream_ids , realm = realm , deactivated = False )
get streams with subscribers .