【发布时间】:2009-04-12 04:36:51
【问题描述】:
这是使用 Google App Engine。我不确定这是否适用于正常的 Django 开发,或者 Google App Engine 是否会发挥作用。如果是,请告诉我,以便我更新此问题的描述。
class MessageModel(db.Model):
to_user_id = db.IntegerProperty()
to_user = db.StringProperty(multiline=False)
message = db.StringProperty(multiline=False)
date_created = db.DateTimeProperty(auto_now_add=True)
现在,当我进行查询时,获取“MessageModel”列表并将其发送到 template.html 以进行绑定,我想包含更多属性,例如“since_date_created”,以输出多久以前最后一个输出,可能会使用 message 属性并添加其他有助于布局的参数,例如 "highlight" 、 "background-color" 等......
我想到的唯一方法是遍历初始查询对象并创建一个新列表,我将在其中添加属性值,然后将其附加回列表。
for msg in messagesSQL:
msg.lalaland = "test"
msg.since_created_time = 321932
msglist.append(msg)
然后,我现在将传递 msglist,而不是传递 template.html messagesSQL。
【问题讨论】:
标签: python django google-app-engine