SyntaxError:在Django上运行syncdb时语法无效 [英] SyntaxError: Invalid Syntax when running syncdb on django

查看:37
本文介绍了SyntaxError:在Django上运行syncdb时语法无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装django-cms变体(wa),并使所有工作正常进行,直到执行'./manage.py syncdb'为止.到那时,我得到如下的追溯:

I'm trying to install a django-cms variant (wagtail) and get everything working up until I am doing the './manage.py syncdb'. At that point I get the traceback as follows:

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之间的语法有很大变化?

Seems like the for loop syntax is okay...any ideas? Or was there a massive change in syntax between python 2.6.6 and python27?

我正在运行在RHEL 6.4(2.6.32-358.el6.x86_64),postgres 8.4.18上运行的PYTHON 2.6.6和DJANGO 1.6.1

I am running PYTHON 2.6.6 and DJANGO 1.6.1 running on RHEL 6.4 (2.6.32-358.el6.x86_64), postgres 8.4.18

任何想法或想法都将不胜感激

Any ideas or thoughts would be greatly appreciated

推荐答案

词典理解是在Python 2.7中添加了.您正在运行2.6.因此,您需要更改此行:

dictionary comprehensions were added in Python 2.7. You're running 2.6. So you need to change this line:

indexed_fields = {field: dict(type="string") for field in indexed_fields}

对此:

indexed_fields = dict((field, dict(type="string")) for field in indexed_fields)

这篇关于SyntaxError:在Django上运行syncdb时语法无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆