Reputation: 17891
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.
Upvotes: 0
Views: 2032
Reputation: 2448
for unbalanced parenthises and other such syntax errors, I find it useful to run pylint on the file. If you use vim, there is a plugin to automatically do this upon save https://github.com/orenhe/pylint.vim
Upvotes: 0
Reputation: 97962
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.
Upvotes: 2