from rest_framework import serializers

from shmitter.likes import services
from .models import Tweet


class TweetSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    is_fan = serializers.SerializerMethodField()

    class Meta:
        model = Tweet
        fields = (
            'id',
            'owner',
            'body',
            'is_fan',
            'total_likes',
            'created',
        )

    def get_is_fan(self, obj):
        """
        Check if a `request.user` has liked a tweet.
        """
        user = self.context.get('request').user
        return services.is_fan(obj, user)

@@ -491,16 +491,24 @@
 lf, obj)
+ -%3E bool
 :%0A      
@@ -561,15 +561,26 @@
 ked 
-a
+this
  tweet
+ (%60obj%60)
 .%0A  

Refactor get_is_fan