Попытка отформатировать Google App Engine DateTimeProperty с помощью модификатора шаблона. - PullRequest
1 голос
/ 22 февраля 2011

Хорошо, у меня есть модель базы данных с полем datetime типа DateTimeProperty ().Я хочу отформатировать это значение в своем шаблоне, поэтому я использую:

{{row.datetime|date:'M j, H:i'}}

Но Google App Engine выдает это исключение:

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 515, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/.../1.348530548823349202/main.py", line 22, in get
    'nominations': row.nominations} for row in data]
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 155, in render
    t = load(template_path, debug)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 183, in load
    template = django.template.loader.get_template(file_name)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 80, in get_template
    template = get_template_from_string(source, origin, template_name)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 88, in get_template_from_string
    return Template(source, origin, name)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 158, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 174, in compile_string
    return parser.parse()
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 273, in parse
    compiled_result = compile_func(self, token)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/defaulttags.py", line 544, in do_for
    nodelist_loop = parser.parse(('endfor',))
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 254, in parse
    filter_expression = self.compile_filter(token.contents)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 338, in compile_filter
    return FilterExpression(token, self)
  File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 558, in __init__
    raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
TemplateSyntaxError: Could not parse the remainder: :'M j, H:i'

Что я делаю не так?

Заранее спасибо.

1 Ответ

3 голосов
/ 25 марта 2011

попробуй

{{row.datetime|date:"M j, H:i"}}
...