import
json
from
datetime
import
date
from
datetime
import
datetime
class
JsonCustomEncoder(json.JSONEncoder):
def
default(
self
, field):
if
isinstance
(field, datetime):
return
o.strftime(
‘%Y-%m-%d %H:%M:%S‘
)
elif
isinstance
(field, date):
return
o.strftime(
‘%Y-%m-%d‘
)
else
:
return
json.JSONEncoder.default(
self
, field)