django 处理时间字段
json.dumps(log_list,default=utils.json_datetime_handler)
import time,hashlib,json import models from django.shortcuts import render,HttpResponse from MadKing import settings from django.core.exceptions import ObjectDoesNotExist def json_date_handler(obj): if hasattr(obj, 'isoformat'): return obj.strftime("%Y-%m-%d") def json_datetime_handler(obj): if hasattr(obj, 'isoformat'): return obj.strftime("%Y-%m-%d %H:%M:%S")