kopia lustrzana https://github.com/longclawshop/longclaw
21 wiersze
576 B
Python
21 wiersze
576 B
Python
|
from rest_framework import serializers
|
||
|
|
||
|
from longclaw.longclawproducts.serializers import ProductVariantSerializer
|
||
|
from longclaw.longclawbasket.models import BasketItem
|
||
|
|
||
|
class BasketItemSerializer(serializers.ModelSerializer):
|
||
|
|
||
|
variant = ProductVariantSerializer()
|
||
|
price = serializers.SerializerMethodField()
|
||
|
total = serializers.SerializerMethodField()
|
||
|
|
||
|
class Meta:
|
||
|
model = BasketItem
|
||
|
fields = "__all__"
|
||
|
|
||
|
def get_price(self, obj):
|
||
|
return obj.price()
|
||
|
|
||
|
def get_total(self, obj):
|
||
|
return obj.total()
|
||
|
|