Answers for "django database if 2 exists"

0

rest api django return value if exists in another table

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')
Posted by: Guest on May-08-2020

Code answers related to "django database if 2 exists"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language