Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#2320 closed defect (fixed)

Template - Python, Tags, example

Reported by: rvernica@… Owned by: Malcolm Tredinnick
Component: Documentation Version: master
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



I tried the example in the documentation page "The Django template language: For Python programmers" section "Writing custom template tags" and I get errors.

  1. 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.

  1. 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" %}


Change History (2)

comment:1 Changed 13 years ago by Malcolm Tredinnick

Owner: changed from Jacob to Malcolm Tredinnick

Urgh. So many errors. :-( I'll fix it.

comment:2 Changed 13 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [3308]) Fixed #2320 -- corrected numerous errors in the custom tag examples in
python_templates.txt. Also fixed an argument parsing error for such tags.

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