feat: enstat2 返回时保留2位小数
This commit is contained in:
parent
909499fc44
commit
6e1ab8a967
|
|
@ -122,4 +122,13 @@ class EnStatSerializer(CustomModelSerializer):
|
||||||
class EnStat2Serializer(CustomModelSerializer):
|
class EnStat2Serializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = EnStat2
|
model = EnStat2
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
ret = super().to_representation(instance)
|
||||||
|
my_dic_keys = list(ret.keys())
|
||||||
|
for key in my_dic_keys:
|
||||||
|
ret_one_val = ret[key]
|
||||||
|
if isinstance(ret_one_val, float):
|
||||||
|
ret[key] = "{:.2f}".format(round(ret_one_val, 2))
|
||||||
|
return ret
|
||||||
Loading…
Reference in New Issue