开发者

django-debug-toolbar logging doesn't work?

开发者 https://www.devze.com 2023-02-16 02:38 出处:网络
I can\'t figure out how to use this plugin... def homepage(request): print request.META[\'HTTP_USER_AGENT\']

I can't figure out how to use this plugin...

def homepage(request):
print request.META['HTTP_USER_AGENT']
print 'test'
return render(request, 'base.html')

after this , in logging tab some output must appear. In console i've got:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US开发者_C百科) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13 test

in django-debug-toolbar logging tab i have "No messages logged."

What do I do wrong?


You need to use the logging module for this to work.

import logging
logger = logging.getLogger(__name__)
logger.debug('Test')

django-toolbar intercepts this call and will add it to the toolbar. When you do print('test') it just goes to standard out.

0

精彩评论

暂无评论...
验证码 换一张
取 消