tags:

views:

31

answers:

2

Hi, after running: "python manage.py runserver", I'm getting the error:

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

Anybody have any suggestions as to what I can do to fix?

Thanks!

+1  A: 

Sounds like you are running a very old version of Python - versions 2.4 and earlier did not support y if x else z. You should upgrade, if possible, or find a version of the massivecoupon package that is compatible with Python 2.4.

Daniel Roseman
+1  A: 

Python's only supported the 'a if b else c' syntax since version 2.5. Are you using an earlier version than that?

If so you could replace line 96 of /home4/usr/.local/lib/python/massivecoupon/paypalxpress/models.py with

self.charged = amount is not None and Decimal(amount)  or None

Should work I think.

Thank you this worked!
JP-django newbie