Opened 14 years ago
Closed 14 years ago
#15138 closed (fixed)
Error in documentation simple_tag decorator.
Reported by: | elbarto | Owned by: | elbarto |
---|---|---|---|
Component: | Documentation | Version: | |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
In http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#shortcut-for-simple-tags :
The new examples, that use takes_context argument, have a second argument (format_string) which are never used.
# The first argument *must* be called "context" here. def current_time(context, format_string): timezone = context['timezone'] return your_get_current_time_method(timezone) register.simple_tag(takes_context=True)(current_time)
@register.simple_tag(takes_context=True) def current_time(context, format_string): timezone = context['timezone'] return your_get_current_time_method(timezone)
I fixed it with a patch.
Attachments (2)
Change History (4)
by , 14 years ago
Attachment: | inclusion_tag_doc.diff added |
---|
comment:1 by , 14 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | simple_tag_doc.diff added |
---|
Included the arguments in the fictitious your_get_current_time_method().
Note:
See TracTickets
for help on using tickets.
Accepted that the example is at least slightly ambiguous; however, the ambiguity should be fixed by using the argument, not by removing it. The point of the example is to demonstrate that "context" must be the first argument, not to say that you can't have other arguments.