请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

TypeError

TypeError at /ansible/adhoclog
isinstance() arg 2 must be a class, type, or tuple of classes and types
Request Method:	GET
Request URL:	http://192.168.158.128:8000/ansible/adhoclog?taskid=2891268
Django Version:	1.8.2
Exception Type:	TypeError
Exception Value:	
isinstance() arg 2 must be a class, type, or tuple of classes and types
Exception Location:	/root/imoocc/taskdo/views.py in default, line 31
Python Executable:	/usr/bin/python
Python Version:	2.7.12
Python Path:	
['/root/imoocc/extra_apps',
 '/root/imoocc/apps',
 '/root/imoocc',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']
Server time:	星期二, 6 十一月 2018 22:48:55 +0800

跟老师一样的代码,访问http://192.168.158.128:8000/ansible/adhoclog?taskid=2891268的时候报了个错,不知道如何处理了

正在回答 回答被采纳积分+3

2回答

提问者 jackanapes 2018-11-07 14:18:49
import datetime
class DateEncoder(json.JSONEncoder ):
    def default(self, obj):
        if isinstance(obj, datetime.datetime):
            return obj.__str__()
        return json.JSONEncoder.default(self, obj)

已经解决了,imoocc/taskdo/views.py这个地方datetime应该写成datetime.datetime

0 回复 有任何疑惑可以回复我~
Jeson 2018-11-07 09:29:04

isinstance() arg 2 must be a class, type, or tuple of classes and types

/root/imoocc/taskdo/views.py in default, line 31

贴下 这个块地方的代码

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信