Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2320 closed defect (fixed)

Template - Python, Tags, example

Reported by: rvernica@… 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.

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

Thanks,
Ray

Change History (2)

comment:1 by Malcolm Tredinnick, 18 years ago

Owner: changed from Jacob to Malcolm Tredinnick

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

comment:2 by Malcolm Tredinnick, 18 years ago

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