serializers.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:valhalla 作者: LCOGT 项目源码 文件源码
def to_representation(self, instance):
        '''
        This method is overridden to remove blank fields from serialized output. We could put this into a subclassed
        ModelSerializer if we want it to apply to all our Serializers.
        :param instance:
        :return:
        '''
        rep = super().to_representation(instance)
        return {key: val for key, val in rep.items() if val}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号