#8031 closed (fixed)
Suppressing exceptions in templates harmful for debugging
Reported by: | Owned by: | Luke Plant | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Even when TEMPLATE_DEBUG is enabled, Django will currently silently suppress all exceptions during template rendering.
This makes it hard to find typos in the template (misspelled variable names), but can also hide other errors.
The concrete problem I hit was the conversion to permalink and the resolver not knowing functions specified directly as object and not string.
As the exception was ignored, all users of the permalink used the empty string.
It would be nice if the exceptions can be easily logged either to stderr (manage.py runserver) or some file, potentially using another debug option in settings.py.
Change History (4)
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:4 by , 16 years ago
If there are any other tags where exceptions are being unhelpfully silenced, please open a new ticket. Silent variable failure is a deliberate feature e.g.
{{ foo.bar.baz }}
should return nothing if foo
is None, or if foo.bar
is None, or if foo.bar.baz
is None.
See this discussion:
http://groups.google.com/group/django-developers/browse_thread/thread/f323338045ac2e5e/
General conclusion: we need to examine individual tags and see whether they should fail silently or not. I agree that it is never useful for the URL tag to fail silently. I'll bring it up on the list