Фикс сериализатора для профиля

main
through-your-tears 9 months ago
parent 6f2e137bf3
commit 6a592c4864

@ -104,8 +104,8 @@ class CustomUserSerializer(serializers.ModelSerializer):
class ProfileSerializer(serializers.ModelSerializer): class ProfileSerializer(serializers.ModelSerializer):
user = serializers.StringRelatedField() user = serializers.StringRelatedField()
count_friends = serializers.SerializerMethodField(read_only=True) count_friends = serializers.SerializerMethodField(method_name='get_friends', read_only=True)
count_subscribers = serializers.SerializerMethodField(read_only=True) count_subscribers = serializers.SerializerMethodField(method_name='get_subscribers', read_only=True)
def get_friends(self, obj): def get_friends(self, obj):
return obj.friends.filter(approved=True).count() return obj.friends.filter(approved=True).count()

Loading…
Cancel
Save