我正在进行一个项目。在这个项目中,我必须更改一些他们通过XML代码实现的报告。 当我使用" python manage.py runserver&#34运行我的项目时,它运行真实,我可以更改我的XML代码并查看chrome上的HTML文件但是当我想查看报告的PDF文件时出现错误那说:
>"IndexError, your list is out of range"
所以我开始调试它,在这个过程中调试器说
"来自django.db.models.constants导入LOOKUP_SEP没有名为constants"的模块。
这是完整的追溯:
>Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace instance at 0x7f45ea1f3b48>
Traceback (most recent call last):
File "/home/rajabi/pycharm-community-2017.1.4/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 589, in __call__
return self.original_func(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/rajabi/Desktop/tina/clone-2017-07-05/rtis/src/saed/activities/models.py", line 7, in <module>
from saed.activities.base import models
File "/home/rajabi/Desktop/tina/clone-2017-07-05/rtis/src/saed/activities/base/models.py", line 16, in <module>
from model_utils.managers import InheritanceManager
File "/usr/local/lib/python2.7/dist-packages/model_utils/managers.py", line 13, in <module>
from django.db.models.constants import LOOKUP_SEP
ImportError: No module named constants
我该怎么办?
我无法改变我的django和python版本。
答案 0 :(得分:1)
回溯的这一部分向您显示错误来自django-model-utils。
File "/usr/local/lib/python2.7/dist-packages/model_utils/managers.py", line 13, in <module>
from django.db.models.constants import LOOKUP_SEP
release notes表示在版本3.0中删除了对Django 1.4的支持。
您可以尝试安装早期版本的django-model-utils,但实际上您应该升级Django。 Django 1.4已经过时且不安全。