Django Urls Configuration Debugging?
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
Solution 1:
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.
Solution 2:
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
Post a Comment for "Django Urls Configuration Debugging?"