fields.py 文件源码

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

项目:sdining 作者: Lurance 项目源码 文件源码
def to_representation(self, value):
        coerce_to_string = getattr(self, 'coerce_to_string', api_settings.COERCE_DECIMAL_TO_STRING)

        if not isinstance(value, decimal.Decimal):
            value = decimal.Decimal(six.text_type(value).strip())

        quantized = self.quantize(value)

        if not coerce_to_string:
            return quantized
        if self.localize:
            return localize_input(quantized)

        return '{0:f}'.format(quantized)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号