# bug fixed: 日期空值判断
This commit is contained in:
parent
9c870d7c1d
commit
0335c3b58b
|
@ -53,10 +53,16 @@ class DeviceInfoSerializer(serializers.ModelSerializer):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_compile_time(self, obj):
|
def get_compile_time(self, obj):
|
||||||
return obj.compile_time.strftime('%Y-%m-%d %H:%M:%S')
|
if obj.compile_time:
|
||||||
|
return obj.compile_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
return None
|
||||||
|
|
||||||
def get_last_connect(self, obj):
|
def get_last_connect(self, obj):
|
||||||
return obj.last_connect.strftime('%Y-%m-%d %H:%M:%S')
|
if obj.last_connect:
|
||||||
|
return obj.last_connect.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
return None
|
||||||
|
|
||||||
def get_last_offline_time(self, obj):
|
def get_last_offline_time(self, obj):
|
||||||
return obj.last_offline_time.strftime('%Y-%m-%d %H:%M:%S')
|
if obj.last_offline_time:
|
||||||
|
return obj.last_offline_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
return None
|
||||||
|
|
Loading…
Reference in New Issue