Check out example codes for "rest api django return value if exists in another table". It will help you in understanding the concepts better.

Code Example 1

class PostSerializer(serializers.ModelSerializer):
    replied = serializers.SerializerMethodField('has_replies')

    def has_replies(post):
        return post.replies.filter(owner=self.context["request"].user).exists()

    class Meta:
        fields = ('id', 'name', 'replied')

Code Example 2

class PostList(generics.ListAPIView):
    def get_queryset(self):
        'current_user_replies_count': 'SELECT COUNT(*) FROM <reply table> WHERE' +
        ' AND owner_id = %s'

Learn ReactJs, React Native from