(self, user, instance, flag='')
return queryset.filter(user=user).exists()
Check if a user is following an instance.
Check if a user is following an instance.
Check if a user is following an instance .
def is_following(self, user, instance, flag=''):
        """
        Check if a user is following an instance.
        """
        if not user or user.is_anonymous:
            return False
        queryset = self.for_object(instance)

        if flag:
            queryset = queryset.filter(flag=flag)
        return queryset.filter(user=user).exists()
def is_following ( self , user , instance , flag = '' ) : if not user or user . is_anonymous : return False queryset = self . for_object ( instance ) if flag : queryset = queryset . filter ( flag = flag ) return queryset . filter ( user = user ) . exists ( )