# 修改时间显示
This commit is contained in:
parent
1a34d08014
commit
b90c21bbbf
|
@ -30,10 +30,13 @@ class DeviceCountSerializer(serializers.ModelSerializer):
|
||||||
return obj.vol
|
return obj.vol
|
||||||
|
|
||||||
def get_calc_time(self, obj):
|
def get_calc_time(self, obj):
|
||||||
return obj.data_time
|
return obj.data_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
|
||||||
class DeviceInfoSerializer(serializers.ModelSerializer):
|
class DeviceInfoSerializer(serializers.ModelSerializer):
|
||||||
|
compile_time = serializers.SerializerMethodField()
|
||||||
|
last_connect = serializers.SerializerMethodField()
|
||||||
|
last_offline_time = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DeviceInfo
|
model = DeviceInfo
|
||||||
|
@ -46,4 +49,13 @@ class DeviceInfoSerializer(serializers.ModelSerializer):
|
||||||
'online',
|
'online',
|
||||||
'last_connect',
|
'last_connect',
|
||||||
'last_offline_time'
|
'last_offline_time'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_compile_time(self, obj):
|
||||||
|
return obj.compile_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
def get_last_connect(self, obj):
|
||||||
|
return obj.last_connect.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
def get_last_offline_time(self, obj):
|
||||||
|
return obj.last_offline_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
|
@ -3,8 +3,8 @@ from rest_framework.pagination import LimitOffsetPagination, PageNumberPaginatio
|
||||||
|
|
||||||
class PostLimitOffsetPagination(LimitOffsetPagination):
|
class PostLimitOffsetPagination(LimitOffsetPagination):
|
||||||
max_limit = 10
|
max_limit = 10
|
||||||
default_limit = 4
|
default_limit = 8
|
||||||
|
|
||||||
|
|
||||||
class PostPageNumberPagination(PageNumberPagination):
|
class PostPageNumberPagination(PageNumberPagination):
|
||||||
page_size = 4
|
page_size = 8
|
||||||
|
|
Loading…
Reference in New Issue