0
Django version 1.4.3
class FooTestCase(TestCase):
def test_deprecation_warning(self):
from django.template.loader import render_to_string
tpl = render_to_string('template.html')
這個生成DeprecationWarning
的Django 1.4:在運行時django.template.loader.render_to_string
C:\Python26\lib\site-packages\django\views\generic\simple.py:8: DeprecationWarning: Function-based generic views have been deprecated; use class-based views instead.
DeprecationWarning爲什麼呢?它不是在遷移頁https://docs.djangoproject.com/en/1.3/topics/generic-views-migration/
你確定它是'render_to_string'那是給你的警告嗎?你能告訴我們回溯嗎? – 2013-03-25 21:06:48
如何生成棄用警告的回溯? – apelliciari 2013-03-25 21:09:41
設置'warnings.filterwarnings('error')',然後你得到一個異常而不是一個警告([見文檔](http://docs.python.org/2.6/library/warnings.html#the-warnings -過濾))。 – 2013-03-25 21:14:44