【发布时间】:2013-05-07 03:32:11
【问题描述】:
我正在尝试设置一个包含对象列表、对象属性名称和对象属性值的调试页面。我正在尝试获取特定对象类型的特定属性的值。我在编码时不知道对象类型或属性。
以下是我为之准备的相关部分:
在我的 test.py 中
if self.request.get('objID'):
qGet = self.request.get
thisObj = db.get(db.Key(qGet('objID')))
template_values = { 'thisObj' : thisObj }
template = JINJA_ENVIRONMENT.get_template('objProp.html')
self.response.write(template.render(template_values))
在我的 objProp.html 模板中
{% if thisObj %}
<ul>List of properties
{% for p in thisObj.properties() %}
<li>{{ p }} : {{ thisObj.p }}</li>
{% endfor %}
</ul>
{% endif %}
但是,由于 thisObj 中没有属性 p,它总是打印出一个空值,这正是我想要打印出循环中特定点处 p 所指的任何属性的值
任何帮助将不胜感激!
【问题讨论】:
标签: python google-app-engine jinja2