Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#8031 closed (fixed)

Suppressing exceptions in templates harmful for debugging

Reported by: joerg@… 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 Luke Plant, 16 years ago

Triage Stage: UnreviewedDesign decision needed

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

comment:2 by Luke Plant, 16 years ago

Owner: changed from nobody to Luke Plant
Status: newassigned

comment:3 by Luke Plant, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [8211]) Fixed #8031 - url tag no longer silences NoReverseMatch exceptions since this is very rarely useful

comment:4 by Luke Plant, 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.

Note: See TracTickets for help on using tickets.
Back to Top