使用Python3和更科学的API写法

This commit is contained in:
virusdefender
2016-11-19 12:32:23 +08:00
parent d9b1141cb9
commit 172fd4b1f4
21 changed files with 335 additions and 270 deletions

View File

@@ -1,18 +0,0 @@
# 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)