from rest_framework import serializers
from clientsmanagement.models import Client


class ClientSerializer(serializers.ModelSerializer):
    email = serializers.SerializerMethodField('get_client_email')
    total_orders = serializers.SerializerMethodField('get_client_total_orders')


    class Meta:
        model = Client
        fields = '__all__'

    def get_client_email(self, client):
        return client.user.email

    def get_client_total_orders(self, client):
        return client.createorder_set.all().count()

bec7d621f6cc6aa293892132b81c120e18049294
<mask token>


class ClientSerializer(serializers.ModelSerializer):
    <mask token>
    <mask token>


    class Meta:
        model = Client
        fields = '__all__'

    def get_client_email(self, client):
        return client.user.email
    <mask token>

<mask token>


class ClientSerializer(serializers.ModelSerializer):
    <mask token>
    <mask token>


    class Meta:
        model = Client
        fields = '__all__'

    def get_client_email(self, client):
        return client.user.email

    def get_client_total_orders(self, client):
        return client.createorder_set.all().count()

<mask token>


class ClientSerializer(serializers.ModelSerializer):
    email = serializers.SerializerMethodField('get_client_email')
    total_orders = serializers.SerializerMethodField('get_client_total_orders')


    class Meta:
        model = Client
        fields = '__all__'

    def get_client_email(self, client):
        return client.user.email

    def get_client_total_orders(self, client):
        return client.createorder_set.all().count()

from rest_framework import serializers
from clientsmanagement.models import Client


class ClientSerializer(serializers.ModelSerializer):
    email = serializers.SerializerMethodField('get_client_email')
    total_orders = serializers.SerializerMethodField('get_client_total_orders')


    class Meta:
        model = Client
        fields = '__all__'

    def get_client_email(self, client):
        return client.user.email

    def get_client_total_orders(self, client):
        return client.createorder_set.all().count()
