【发布时间】:2014-04-22 22:57:35
【问题描述】:
这是 Wagtail 中的一行代码(带有非常酷的 UI 的 Django 变体 CMS)。问题是它是为 Python 2.7 编写的,我在共享主机上使用 Python 2.6 和 Django + FastCGI。
我已经更改了之前发现的语法错误by mhlester 但无法弄清楚这一点:
>>> for attr in json_attrs
File "<stdin>", line 1
for attr in json_attrs
^
SyntaxError: invalid syntax
原代码:
if use_json: # Return a json response
if search_results:
search_results_json = []
for result in search_results:
result_specific = result.specific
search_results_json.append({
attr: getattr(result_specific, attr)
for attr in json_attrs
if hasattr(result_specific, attr)
})
请帮忙?
【问题讨论】:
标签: python django python-2.7 python-2.6 wagtail