wagtail-longclaw/longclaw/longclawbasket/serializers.py

21 wiersze
576 B
Python
Czysty Zwykły widok Historia

2017-02-03 10:04:57 +00:00
from rest_framework import serializers
2017-02-17 09:03:21 +00:00
from longclaw.longclawproducts.serializers import ProductVariantSerializer
from longclaw.longclawbasket.models import BasketItem
2017-02-03 10:04:57 +00:00
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()