灭蚊灯计数log的with_device条件,增加weather_code
This commit is contained in:
parent
0e8040e4b1
commit
937c457afd
|
@ -167,6 +167,7 @@ class DeviceCountSerializer(serializers.ModelSerializer):
|
|||
|
||||
class DeviceCountWithInfoSerializer(DeviceCountSerializer):
|
||||
location_id = serializers.SerializerMethodField()
|
||||
weather_code = serializers.SerializerMethodField()
|
||||
point_x = serializers.SerializerMethodField()
|
||||
point_y = serializers.SerializerMethodField()
|
||||
|
||||
|
@ -183,6 +184,7 @@ class DeviceCountWithInfoSerializer(DeviceCountSerializer):
|
|||
'longitude',
|
||||
'latitude',
|
||||
'location_id',
|
||||
'weather_code',
|
||||
'point_x',
|
||||
'point_y',
|
||||
]
|
||||
|
@ -194,6 +196,13 @@ class DeviceCountWithInfoSerializer(DeviceCountSerializer):
|
|||
return device.location_id
|
||||
return None
|
||||
|
||||
def get_weather_code(self, obj):
|
||||
device = self.device
|
||||
if device:
|
||||
if device.weather_code:
|
||||
return device.weather_code
|
||||
return None
|
||||
|
||||
def get_point_x(self, obj):
|
||||
device = self.device
|
||||
if device:
|
||||
|
|
Loading…
Reference in New Issue