Code

Opened 7 years ago

Closed 7 years ago

#4267 closed (fixed)

a bug in "The Django template language: For Python programmers"

Reported by: keisuke.nishida@… Owned by: jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

Description

I have found a possible bug in the following page:

http://www.djangoproject.com/documentation/templates_python/#writing-the-compilation-function

You refer to "token.contents[0]" at several places in the sample code like this:

def do_current_time(parser, token):
    try:
        # split_contents() knows not to split quoted strings.
        tag_name, format_string = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents[0]

I believe "token.contents[0]" returns a single character, which is not very informative
and not what you want here. Maybe it should have been "token.contents.split()[0]"?

The same applies to 0.95/0.96 docs.

Best regards,

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by mtredinnick

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

(In [5188]) Fixed #4267 -- In example code, extract the template tag name correctly in
error messages where Token.split_contents() has failed. Thanks,
keisuke.nishida@….

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.