码迷,mamicode.com
首页 > 其他好文 > 详细

REST功能模块-Serialization

时间:2018-06-04 23:23:45      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:market   else   cat   dsc   功能   TE   work   ima   image   

from rest_framework import serializers
from goods.models import Goods, GoodsCategory

class GoodsCategorySerializer(serializers.ModelSerializer):
class Meta:
model = GoodsCategory
fields = "__all__"


class GoodsSerializer(serializers.ModelSerializer):
category = GoodsCategorySerializer()

class Meta:
model = Goods
# fields = ("category", "name", "market_price", "add_time", "goods_front_image") # 序列化知道字段
fields = "__all__" # __all__ 序列化所有字段

REST功能模块-Serialization

标签:market   else   cat   dsc   功能   TE   work   ima   image   

原文地址:https://www.cnblogs.com/YingLai/p/9136343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!