Django - 找到警告来自的模块?

时间:2013-02-02 03:43:13

标签: django django-testing django-manage.py

这是我的测试输出。我无法弄清楚坏DateTimeField的设置位置,因为我只能看到:/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/的初始化的.py

这对缩小问题并不是很有用。如何获得有关导致警告的更多详细信息?堆栈跟踪会很好!

感谢您的帮助!

python -W manage.py test

Creating test database for alias 'default'...
............................................................................................................................................................................................................................................./home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/conf/urls/defaults.py:3: PendingDeprecationWarning: django.conf.urls.defaults is deprecated; use django.conf.urls instead
  PendingDeprecationWarning)
/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2013-02-01 00:00:00) while time zone support is active.
  RuntimeWarning)
/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2013-02-01 23:59:59.999999) while time zone support is active.
  RuntimeWarning)
/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:761: RuntimeWarning: DateTimeField received a naive datetime (2013-01-31 00:00:00) while time zone support is active.
  RuntimeWarning)
/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:761: RuntimeWarning: DateTimeField received a naive datetime (2013-02-02 00:00:00) while time zone support is active.
  RuntimeWarning)
/home/workspace/ticktockgo/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:761: RuntimeWarning: DateTimeField received a naive datetime (2013-03-01 00:00:00) while time zone support is active.
  RuntimeWarning)
..............ss.s..............................................................................................
----------------------------------------------------------------------
Ran 491 tests in 20.825s

OK (skipped=3)

1 个答案:

答案 0 :(得分:2)

warnings.showwarning替换为使用traceback的函数来查找并显示当前堆栈帧。