1

好吧,我有一个日期时间字段类型为 DateTimeProperty() 的数据库模型。我想在我的模板中格式化这个值,所以我使用:

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

但是 Google App Engine 抛出了这个异常:

回溯(最近一次通话最后):
  __call__ 中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py”,第 515 行
    handler.get(*groups)
  文件“/base/data/home/apps/.../1.348530548823349202/main.py”,第 22 行,在 get
    'nominations': row.nominations} 用于数据中的行]
  文件“/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py”,第 155 行,在渲染中
    t = 加载(模板路径,调试)
  加载中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/template.py”,第 183 行
    模板 = django.template.loader.get_template(file_name)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py”,第 80 行,在 get_template
    模板 = get_template_from_string(来源、来源、模板名称)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/loader.py”,第 88 行,在 get_template_from_string
    返回模板(来源、来源、名称)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 158 行,在 __init__
    self.nodelist = compile_string(template_string, origin)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 174 行,在 compile_string
    返回 parser.parse()
  解析中的文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 273 行
    编译结果 = 编译函数(自我,令牌)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/defaulttags.py”,第 544 行,在 do_for
    nodelist_loop = parser.parse(('endfor',))
  解析中的文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 254 行
    filter_expression = self.compile_filter(token.contents)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 338 行,在 compile_filter
    返回FilterExpression(令牌,自我)
  文件“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/template/__init__.py”,第 558 行,在 __init__
    引发 TemplateSyntaxError,“无法解析余数:%s”% token[upto:]
TemplateSyntaxError:无法解析剩余部分::'M j,H:i'

我究竟做错了什么?

先感谢您。

4

1 回答 1

3

尝试

{{row.datetime|date:"M j, H:i"}}
于 2011-03-25T15:29:52.513 回答