diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-02-13 15:44:04 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-02-13 15:44:04 +0000 |
| commit | c61d7e195f2fb3bebbd124ff814af3a8c2e59c1f (patch) | |
| tree | 2ad7e4f5902d5ff351e6976d58402c0c8b6cd1d1 /docs/templates_python.txt | |
| parent | 7ac5a6e27da9bd6a10da068f8980ba023d323a0d (diff) | |
Renamed date_to_format function in docs/templates_python.txt example so as to make it not sound like a conversion function. Thanks, linoj
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4502 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/templates_python.txt')
| -rw-r--r-- | docs/templates_python.txt | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/templates_python.txt b/docs/templates_python.txt index 3d6bfd7040..a6b565ed5c 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -829,12 +829,12 @@ Now your tag should begin to look like this:: def do_format_time(parser, token): try: # split_contents() knows not to split quoted strings. - tag_name, date_to_format, format_string = token.split_contents() + tag_name, date_to_be_formatted, format_string = token.split_contents() except ValueError: raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents[0] if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name - return FormatTimeNode(date_to_format, format_string[1:-1]) + return FormatTimeNode(date_to_be_formatted, format_string[1:-1]) You also have to change the renderer to retrieve the actual contents of the ``date_updated`` property of the ``blog_entry`` object. This can be @@ -846,13 +846,13 @@ current context, available in the ``render`` method:: from django.template import resolve_variable import datetime class FormatTimeNode(template.Node): - def __init__(self, date_to_format, format_string): - self.date_to_format = date_to_format + def __init__(self, date_to_be_formatted, format_string): + self.date_to_be_formatted = date_to_be_formatted self.format_string = format_string def render(self, context): try: - actual_date = resolve_variable(self.date_to_format, context) + actual_date = resolve_variable(self.date_to_be_formatted, context) return actual_date.strftime(self.format_string) except VariableDoesNotExist: return '' |
