class ShopCartLisetSerializer(serializers.ModelSerializer): goods = GoodsSerializers(many=False) class Meta: model = ShoppingCart fields = ['goods', 'nums']
class UserFavDetailSerializer(serializers.ModelSerializer): # 通过goods_id拿到商品信息。就需要嵌套的Serializer goods = GoodsSerializers() class Meta: model = UserFav fields = ("goods", "id")
class ShoppingCartDatilSerializers(serializers.ModelSerializer): # 一条购物车关系记录对应的只有一个goods。 goods = GoodsSerializers(many=False, read_only=True) class Meta: model = ShoppingCart fields = ("goods", "nums")
class OrderGoodsSerializer(serializers.ModelSerializer): goods = GoodsSerializers(many=False) # print('********************',goods) class Meta: model = OrderGoods fields = '__all__'
class UserFavDetailSerializer(serializers.ModelSerializer): ''' 用户收藏 ''' goods = GoodsSerializers() class Meta: model = UserFav fields = ("goods", "id")
class OrderGoodsSerialzier(serializers.ModelSerializer): goods = GoodsSerializers(many=False) class Meta: model = OrderGoods fields = "__all__"
class UserFavDetailSerializers(serializers.ModelSerializer): goods = GoodsSerializers() class Meta: model = UserFav fields = ('goods', 'id')
class ShoppingCartDetailSerializers(serializers.ModelSerializer): goods = GoodsSerializers(many=False) class Meta: model = ShoppingCart fields = '__all__'
class ShopCartDetailSerializer(serializers.Serializer): goods = GoodsSerializers(many=False, read_only=True) class Meta: model = ShoppingCart fields = ('goods', 'nums')
class UserFavListSerializers(serializers.ModelSerializer): goods = GoodsSerializers() class Meta: model = UserFav fields = '__all__'