Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#2320 closed defect (fixed)

Template - Python, Tags, example

Reported by: rvernica@… Owned by: mtredinnick
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: UI/UX:

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 Changed 9 years ago by mtredinnick

  • Owner changed from jacob to mtredinnick

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

comment:2 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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