#2320 closed defect (fixed)
Template - Python, Tags, example
Reported by: | Owned by: | Malcolm Tredinnick | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I tried the example in the documentation page "The Django template language: For Python programmers" http://www.djangoproject.com/documentation/templates_python/ section "Writing custom template tags" and I get errors.
- When I use the tag I like:
{% current_time "%Y-%M-%d %I:%M %p" %}
I get:
Exception Type: TemplateSyntaxError Exception Value: current_time takes 1 arguments
If I remove the spaces within the string argument:
{% current_time "%Y-%M-%d%I:%M%p" %}
it does not give this error.
- In the "Shortcut for simple tags" case, I get:
Exception Type: AttributeError Exception Value: 'str' object has no attribute 'contents'
The error comes from line:
tag_name, format_string = token.contents.split(None, 1)
token variable is an empty string.
I use it with:
{% current_time "%Y-%M-%d%I:%M%p" %}
Thanks,
Ray
Change History (2)
comment:1 by , 18 years ago
Owner: | changed from | to
---|
comment:2 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Urgh. So many errors. :-( I'll fix it.