#2016 closed enhancement (fixed)
[patch] Decorator for template tags that load objects
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The django.template module includes two convenient decorators for making certain common template tags, simple_tag for inserting strings and inclusion_tag for including other templates. Another common idiom is loading an object into the template. For example:
{% get_recent_articles 4 as recent_articles %}
This patch includes an object_tag decorator that makes this kind of tag easy.
I'm new to Django and don't know how this fits in with the refactoring going on now, but I found it quite useful.
Attachments (7)
Change History (17)
by , 19 years ago
Attachment: | object_tag.patch added |
---|
comment:1 by , 19 years ago
Status: | new → assigned |
---|
comment:2 by , 18 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 18 years ago
Needs documentation: | set |
---|---|
Needs tests: | unset |
comment:4 by , 17 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Design decision needed → Accepted |
by , 15 years ago
Attachment: | 0001-Moves-the-argument-matching-to-a-separate-function.diff added |
---|
by , 15 years ago
Attachment: | 0002-Adds-the-object_tag-decorator.diff added |
---|
by , 15 years ago
Attachment: | 0003-Adds-documentation-for-object_tag.diff added |
---|
by , 15 years ago
Attachment: | 0004-Adds-tests-for-object_tag.diff added |
---|
comment:5 by , 15 years ago
Added my own attempt to provide an improved patch along with documentation and tests.
comment:6 by , 15 years ago
Please provide a single diff from the root of the source tree, rather than several files.
by , 15 years ago
Attachment: | object_tag-combined-patch.diff added |
---|
Following Alex's advice by providing a single patch file
comment:8 by , 14 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
Updated patch for current trunk.
by , 14 years ago
Attachment: | fix2016.patch added |
---|
comment:9 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Let's be bold and close this ticket. @simple_tag has a takes_context parameter now making this ticket obsolete.
comment:10 by , 14 years ago
Just for posterity, the resolution would actually be duplicate of #14262. Although it is more recent, it also has a more up-to-date discussion about the preferred API.
Did Adrian's "assigned" means that this was approved?