小编Chr*_*ris的帖子

Python - Google App Engine - Django模板中的方法

我来自Rails编程经验.

我正在使用Django模板在Google App Engine上用Python编写应用程序.

我不能在日期时间调用strftime("%I:%M%p").

在我的main.py文件中,我有:

import datetime
....
class Report(db.Model):
    date = db.DateTimeProperty(auto_now_add = True)
Run Code Online (Sandbox Code Playgroud)

我将所有报告传递给模板,并在模板中传递:

{% for report in reports %}
<tr>
    <td>{{ report.date.strftime("%I:%M %p") }}</td>
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我知道我有一个日期时间对象,因为我可以这样做:

{{ report.date.day }} 
Run Code Online (Sandbox Code Playgroud)

要么:

{{ report.date.minute }} 
Run Code Online (Sandbox Code Playgroud)

很好,他们返回他们应该返回的东西.

当我有:

 {{ report.date.strftime("%I:%M %p") }}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:] TemplateSyntaxError: Could not parse the remainder: ("%I:%M %p")

我如何让strftime工作?

python methods google-app-engine django-templates

2
推荐指数
1
解决办法
681
查看次数

如何防止ComboBox滚动?C#

我有一个ComboBox.用户无法意外滚动并更改所选值至关重要.

如何在使用滚动时阻止ComboBox更改值和文本?谢谢.

Visual Studio 2008

c# scroll combobox winforms

1
推荐指数
1
解决办法
4853
查看次数