views:

80

answers:

1

What's the best method to debug Django's url configurations? Sometime it just throw out a Unhandled Exception without any hints if there is an error in urls.py

Sometimes it throws out errors like "unbalanced parenthesis" but I still dont know which line in urls.py caused the error.

+1  A: 

For underlying application errors, I sometimes find it helpful to toggle the value of TEMPLATE_DEBUG in settings.py (django docs here). Often this gives me the backtrace I need to spot syntax errors outside the template, or other bone-headed code that I might have botched.

If that fails, try importing your view module from the django shell:

$ python manage.py shell
>>> from myapp_that_causes_problems import views

If there's truly a syntax error, this will bomb in the import and expose the offending line immediately.

Jarret Hardie