Adrian Holovaty wrote:
On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:
Thanks. What about the case where I need to get debugging output from deep in
a routine and no obvious (to me, at least) way to bubble it up into the web
browser?

A simple solution is to raise an exception at any point. It'll bubble
up to the Web browser as long as you have DEBUG=True. (If you have
DEBUG=False, Django will attempt to send an e-mail with the full
traceback to the people defined in the ADMINS setting.)

Personally I use "assert False" for this. For example, if I wanted to
see the value of variable foo, I'd do this:

    assert False, foo

How do I make this work?

In mysite/apps/simple/views.py I have:

  from django.core.extensions import render_to_response
  def saysomething(request):
    assert False, "Test assert"
    return render_to_response('base', {'message': "My message."})

The inclusion of the 'assert' line causes it to throw exception "TemplateDoesNotExist: 500" and no sign of the output from assert anywhere.

Thanks,
Michael

Reply via email to