Python Datetime不能使用tastypie进行json序列化

Python Datetime不能使用tastypie进行json序列化,python,json,django,tastypie,Python,Json,Django,Tastypie,这是我的time_now()函数 我把它称为在我的SkyGroupResource文件中创建的init 通过以下方式: def obj_create(self,bundle,**kwargs): return super(SkyGroupResource, self).obj_create(bundle, owner_id=bundle.request.user.skyuser, created_at = time_tools.time_now()) 在其他资源中,我有以下字段: g

这是我的time_now()函数

我把它称为在我的SkyGroupResource文件中创建的init 通过以下方式:

def obj_create(self,bundle,**kwargs):

    return super(SkyGroupResource, self).obj_create(bundle, owner_id=bundle.request.user.skyuser, created_at = time_tools.time_now())
在其他资源中,我有以下字段:

group_id = fields.ForeignKey(SkyGroupResource,'group_id',null=False)
当我试图在POST上使用我的第二个资源时,我得到了以下错误

TypeError:datetime.datetime(2015,5,19,19,51,33,8253, tzinfo=)不可JSON序列化


有什么想法吗?

您可以先使用
str(datetime.now())
将日期转换为字符串

*编辑:您应该看看:

group_id = fields.ForeignKey(SkyGroupResource,'group_id',null=False)