fix: EnvDataSerializer round处理2
This commit is contained in:
parent
68933e3e16
commit
3e75683ee1
|
@ -129,6 +129,7 @@ class EnvDataSerializer(CustomModelSerializer):
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
representation = super().to_representation(instance)
|
representation = super().to_representation(instance)
|
||||||
for field_name in ("dust_rtd", "dust_zs", "temperature", "pressure", "speed", "humidity", "flux", "pm25", "pm10", "tsp", "wind_speed", "so2_rtd", "so2_zs", "nox_rtd", "nox_zs", "o2"):
|
for field_name in ("dust_rtd", "dust_zs", "temperature", "pressure", "speed", "humidity", "flux", "pm25", "pm10", "tsp", "wind_speed", "so2_rtd", "so2_zs", "nox_rtd", "nox_zs", "o2"):
|
||||||
|
if representation[field_name]:
|
||||||
representation[field_name] = round(representation[field_name], 4)
|
representation[field_name] = round(representation[field_name], 4)
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue