from rest_framework import serializers
from Order.models import OrderItem, Order
from Product.serializers import productSerializer


class OrderItemSerializer(serializers.ModelSerializer):
    product = productSerializer(read_only=True)
    total = serializers.ReadOnlyField(source='orderItemTotal', read_only=True)

    class Meta:
        model = OrderItem
        fields = ["id", "order", "quantity",
                  "product", "total", "date_added"]
        read_only_fields = ["date_added", "order"]


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(
        source='getordertotalPrice', read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)

    class Meta:
        model = Order
        fields = ["id", "tatolorderPrice", "itemorder"]

b354dceba518c64117a74e3dd7dca208d942ce85
<mask token>


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(source='getordertotalPrice',
        read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)


    class Meta:
        model = Order
        fields = ['id', 'tatolorderPrice', 'itemorder']

<mask token>


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


    class Meta:
        model = OrderItem
        fields = ['id', 'order', 'quantity', 'product', 'total', 'date_added']
        read_only_fields = ['date_added', 'order']


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(source='getordertotalPrice',
        read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)


    class Meta:
        model = Order
        fields = ['id', 'tatolorderPrice', 'itemorder']

<mask token>


class OrderItemSerializer(serializers.ModelSerializer):
    product = productSerializer(read_only=True)
    total = serializers.ReadOnlyField(source='orderItemTotal', read_only=True)


    class Meta:
        model = OrderItem
        fields = ['id', 'order', 'quantity', 'product', 'total', 'date_added']
        read_only_fields = ['date_added', 'order']


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(source='getordertotalPrice',
        read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)


    class Meta:
        model = Order
        fields = ['id', 'tatolorderPrice', 'itemorder']

from rest_framework import serializers
from Order.models import OrderItem, Order
from Product.serializers import productSerializer


class OrderItemSerializer(serializers.ModelSerializer):
    product = productSerializer(read_only=True)
    total = serializers.ReadOnlyField(source='orderItemTotal', read_only=True)


    class Meta:
        model = OrderItem
        fields = ['id', 'order', 'quantity', 'product', 'total', 'date_added']
        read_only_fields = ['date_added', 'order']


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(source='getordertotalPrice',
        read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)


    class Meta:
        model = Order
        fields = ['id', 'tatolorderPrice', 'itemorder']

from rest_framework import serializers
from Order.models import OrderItem, Order
from Product.serializers import productSerializer


class OrderItemSerializer(serializers.ModelSerializer):
    product = productSerializer(read_only=True)
    total = serializers.ReadOnlyField(source='orderItemTotal', read_only=True)

    class Meta:
        model = OrderItem
        fields = ["id", "order", "quantity",
                  "product", "total", "date_added"]
        read_only_fields = ["date_added", "order"]


class OrderSerializer(serializers.ModelSerializer):
    tatolorderPrice = serializers.ReadOnlyField(
        source='getordertotalPrice', read_only=True)
    itemorder = OrderItemSerializer(many=True, read_only=True)

    class Meta:
        model = Order
        fields = ["id", "tatolorderPrice", "itemorder"]
