wagtail-longclaw/longclaw/basket/serializers.py

21 wiersze
560 B
Python
Czysty Zwykły widok Historia

2017-02-03 10:04:57 +00:00
from rest_framework import serializers
from longclaw.products.serializers import ProductVariantSerializer
from longclaw.basket.models import BasketItem
class BasketItemSerializer(serializers.ModelSerializer):
2017-02-03 17:24:41 +00:00
variant = ProductVariantSerializer()
2017-02-03 10:04:57 +00:00
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()