How to override the stack trace template in django?
How can I change the template that django uses to display a stack trace when DEBUG mode is enabled and an exception gets caught at the top of the stack resulting in a 500?
Apologies if this is a dupe question -- I'm sure the answer is stated simply somewhere, but owing to the nature of the search terms I'm having a ha开发者_开发百科rd time tracking down the answer.
Thanks!
Well, the trace is formatted by an internal template in views/debug.py
. Look for TECHNICAL_500_TEMPLATE and for get_traceback_html() where it's used. So you could copy that template, hack it as you like, then monkeypatch it into django.view.debug. It ain't pretty, but this is fairly deep into the guts so you have to expect to get some "stuff" on you.
Define a handler500
in the URLconf.
精彩评论