from rest_framework import serializers from apps.payment.models import AuthorBalance from .user import UserSerializer class AuthorBalanceCreateSerializer(serializers.ModelSerializer): class Meta: model = AuthorBalance fields = ( 'id', 'author', 'type', 'amount', 'commission', 'status', 'payment', 'card', 'cause', ) read_only_fields = ( 'id', 'author', 'type', 'payment', ) def to_representation(self, instance): return AuthorBalanceSerializer(instance, context=self.context).to_representation(instance) class AuthorBalanceSerializer(serializers.ModelSerializer): author = UserSerializer() class Meta: model = AuthorBalance fields = ( 'id', 'author', 'type', 'amount', 'commission', 'status', 'payment', 'card', 'cause', ) read_only_fields = ( 'id', 'author', 'type', 'payment', )