我來自Rails編程經驗。Python - Google App Engine - Django模板中的方法
我使用Django模板在Google App Engine上編寫了一個應用程序。
我無法在日期時間調用strftime(「%I:%M%p」)。
在我的main.py文件我有:
import datetime
....
class Report(db.Model):
date = db.DateTimeProperty(auto_now_add = True)
我通過所有的模板,在模板上的報告我有:
{% for report in reports %}
<tr>
<td>{{ report.date.strftime("%I:%M %p") }}</td>
</tr>
{% endfor %}
我知道我有一個DateTime對象,因爲我可以這樣做:
{{ report.date.day }}
或:
{{ report.date.minute }}
就好,他們返回他們應該返回的東西。
當我有:
{{ report.date.strftime("%I:%M %p") }}
我得到的錯誤:
raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:] TemplateSyntaxError: Could not parse the remainder: ("%I:%M %p")
我怎麼strftime的工作?
謝謝! 我做了'{{report.date | date:「f A」}}'' – Chris