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