From 0335c3b58bf1789ff057469dd40a4c311b738395 Mon Sep 17 00:00:00 2001 From: xianfuxing Date: Wed, 8 Aug 2018 17:02:19 +0800 Subject: [PATCH] =?UTF-8?q?#=20bug=20fixed:=20=E6=97=A5=E6=9C=9F=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/counter/api/serializers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/counter/api/serializers.py b/apps/counter/api/serializers.py index b99836d..316a420 100644 --- a/apps/counter/api/serializers.py +++ b/apps/counter/api/serializers.py @@ -53,10 +53,16 @@ class DeviceInfoSerializer(serializers.ModelSerializer): ] 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): - 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): - 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