这不是第一次发生在我身上,所以现在我正在寻找答案,因为我完全难过了.
我现在已经在生产环境中运行了3个多月的代码并且它工作得非常好,然后我开始在python中出现错误.
'method_descriptor' object has no attribute 'today'
Exception Value:
'method_descriptor' object has no attribute 'today'
Exception Location: /admin/views/create.py in process, line 114
/admin/views/create.py in process
order = Orders(uid=0, accepted=0, canview='', files=0, date=datetime.date.today(), due=dueDate,
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在使用以下内容,它在python shell中运行得非常好:
>>> import datetime
>>> datetime.date.today()
>>> datetime.date(2011, 9, 27)
Run Code Online (Sandbox Code Playgroud)
您的代码正在datetime.datetime
某处导入,而不仅仅是datetime
,例如from datetime import datetime
.
>>> import datetime
>>> datetime.datetime.date.today()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'method_descriptor' object has no attribute 'today'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2090 次 |
最近记录: |