#20962 closed Cleanup/optimization (fixed)
Documentation on template tag render() methods is inconsistent with core tags.
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | afraid-to-commit |
Cc: | Daniele Procida | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
According to the documentation:
render() should never raise TemplateSyntaxError or any other exception. It should fail silently, just as template filters should.
As I write this, at a glance, URLNode.render(), WidthRatio.render(), both raise TemplateSyntaxError. So do some of those outside defaulttags, such as CacheNode.render(), and it looks like ExtendsNode.get_parent() does too (ForLoopNode.render() does, but is exempted from this list because it explicitly only does so if TEMPLATE_DEBUG is True)
I'm marking this as a documentation issue, as I think the wording should be changed to reflect that ideally template tags should fail silently [at least in production, where DEBUG and TEMPLATE_DEBUG should be False], but it is understandable that sometimes they cannot, which is I assume why Django hasn't "dogfooded" it's own advice here.
The links above should all be to the files/documentation as they stand when writing this, pinned to 1.6 or the last commit for temporal accuracy going forwards.
Change History (7)
comment:1 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 11 years ago
Cc: | added |
---|---|
Keywords: | afraid-to-commit added |
comment:3 by , 11 years ago
comment:4 by , 11 years ago
Has patch: | set |
---|
I've proposed a change in this PR: https://github.com/django/django/pull/1737.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I've marked this ticket as especially suitable for first-time committers or people following the Don't be afraid to commit tutorial. If you're tackling this ticket, please don't hesitate to ask me for guidance if you'd like any, either here or on the Django IRC channels, where I can be found as EvilDMP.