开发者

Trying to format Google App Engine DateTimeProperty with a template modifier

开发者 https://www.devze.com 2023-02-12 08:13 出处:网络
Well, I\'ve a database model with a datetime fiel开发者_运维技巧d of type DateTimeProperty(). I want to format this value in my template, so I\'m using:

Well, I've a database model with a datetime fiel开发者_运维技巧d of type DateTimeProperty(). I want to format this value in my template, so I'm using:

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

But Google App Engine throws this exception:

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'

What am I doing wrong?

Thank you in advance.


try

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号