from rest_framework import serializers
from producers_products_variants.models.products_vairants import ProductsVariants

class ProductsVariantsSerializer(serializers.ModelSerializer):
    id = serializers.ReadOnlyField()
    products_color_name = serializers.CharField(source='products_color.name', read_only=True)
    product_type_and_size_name = serializers.CharField(source='product_type_and_size.name', read_only=True)


    class Meta:
        model = ProductsVariants
        fields = ['id', 'product', 'products_color', 'products_color_name', 'product_type_and_size','product_type_and_size_name', 'quantity']
        read_only_fields = ['id','products_color_name','product_type_and_size_name']