我正在尝试安装一个django-cms变种(wagtail)并让一切正常,直到我在做'./manage.py syncdb'。那时我得到如下追溯:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/template/loaders/app_directories.py", line 23, in <module>
mod = import_module(app)
File "/opt/software/virt_env/virt1/lib/python2.6/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/opt/software/virt_env/virt1/src/wagtail/wagtail/wagtailsearch/__init__.py", line 1, in <module>
from indexed import Indexed
File "/opt/software/virt_env/virt1/src/wagtail/wagtail/wagtailsearch/indexed.py", line 43
indexed_fields = {field: dict(type="string") for field in indexed_fields}
^
SyntaxError: invalid syntax
似乎for循环语法还可以......任何想法?或者python 2.6.6和python27之间的语法有很大的变化吗?
我在RHEL 6.4(2.6.32-358.el6.x86_64)上运行PYTHON 2.6.6和DJANGO 1.6.1,postgres 8.4.18
非常感谢任何想法或想法
答案 0 :(得分:0)
dictionary comprehensions were added in Python 2.7。你正在运行2.6。所以你需要改变这一行:
indexed_fields = {field: dict(type="string") for field in indexed_fields}
进入这个:
indexed_fields = dict((field, dict(type="string")) for field in indexed_fields)