运行后:“python manage.py runserver”,我收到错误:
Validating models...
Unhandled exception in thread started by <function inner_run at 0xc942a8>
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/core/management/base.py", line 245, in validate
num_errors = get_validation_errors(s, app)
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/core/management/validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/home4/usr/.local/lib/python/Django-1.2.1-py2.4.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home4/usr/.local/lib/python/massivecoupon/paypalxpress/models.py", line 96
self.charged = Decimal(amount) if amount is not None else None
^
SyntaxError: invalid syntax
有人对我能解决什么问题有任何建议吗?
谢谢!
答案 0 :(得分:1)
听起来你正在运行一个非常旧的Python版本 - 版本2.4及更早版本不支持y if x else z
。如果可能,您应该升级,或者找到与Python 2.4兼容的largecoupon软件包版本。
答案 1 :(得分:1)
Python仅支持自2.5版以来的'a if b else c'语法。您使用的是早期版本吗?
如果是这样,您可以用
替换/home4/usr/.local/lib/python/massivecoupon/paypalxpress/models.py的第96行self.charged = amount is not None and Decimal(amount) or None
我认为应该工作。