code: 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()
docs: Check if a user is following an instance.