mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-17 01:54:52 +00:00
eb02a00859
增加部分测试和注释,完善国际化
18 lines
461 B
Python
18 lines
461 B
Python
# coding=utf-8
|
|
import json
|
|
|
|
from django.utils import timezone
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
class JSONField(serializers.Field):
|
|
def to_representation(self, value):
|
|
return json.loads(value)
|
|
|
|
|
|
class DateTimeTZField(serializers.DateTimeField):
|
|
def to_representation(self, value):
|
|
self.format = "%Y-%-m-%d %-H:%-M:%-S"
|
|
value = timezone.localtime(value)
|
|
return super(DateTimeTZField, self).to_representation(value) |