所以我设置了使用django 1.3和zc.buildout的旧python项目。当我运行服务器时,我收到以下错误:
这是完整的堆栈跟踪:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.3
Python Version: 2.7.6
Installed Applications:
['filebrowser',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'sugar',
'registration',
'webtopay',
'pagination',
'rest_framework',
'rest_framework.authtoken',
'mptt',
'feincms',
'feincms.module.page',
'esavadai',
'esavadai.documents',
'esavadai.users',
'esavadai.bookmarks',
'esavadai.services',
'esavadai.statistics',
'esavadai.orders',
'esavadai.emails',
'debug_toolbar',
'django_extensions',
'test_utils']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/home/marijus/workspace/esavadai/eggs/Django-1.3-py2.7.egg/django/core/handlers/base.py" in get_response
89. response = middleware_method(request)
File "/home/marijus/workspace/esavadai/eggs/Django-1.3-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/marijus/workspace/esavadai/project/esavadai/urls.py" in <module>
8. admin.autodiscover()
File "/home/marijus/workspace/esavadai/eggs/Django-1.3-py2.7.egg/django/contrib/admin/__init__.py" in autodiscover
26. import_module('%s.admin' % app)
File "/home/marijus/workspace/esavadai/eggs/Django-1.3-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/marijus/workspace/esavadai/eggs/django_extensions-1.3.9-py2.7.egg/django_extensions/admin/__init__.py" in <module>
23. from django_extensions.admin.widgets import ForeignKeySearchInput
File "/home/marijus/workspace/esavadai/eggs/django_extensions-1.3.9-py2.7.egg/django_extensions/admin/widgets.py" in <module>
7. from django.utils.text import Truncator
Exception Type: ImportError at /
Exception Value: cannot import name Truncator
这是我的buildout文件:
[buildout]
parts =
apacheconf
production.py
my.cnf
mkdir
django
# scribd-patch
jquery-ui
tinymce
eggs =
PIL
South
django
django-annoying
django-sugar
python-scribd
django-mptt
django-filebrowser-no-grappelli
django-webtopay
django-pagination
django-registration
feincms
mock
simplejson
djangorestframework
djangorestframework-csv
markdown
extra-paths = project
allowed-eggs-from-site-packages =
PIL
setuptools
distribute
extensions = mr.developer
sources = sources
sources-dir = parts
auto-checkout = *
download-cache = cache
versions = versions
servername = www.myproject.com
serveradmin = admin@myproject.com
[sources]
# my.package = svn http://example.com/svn/my.package/trunk
# some.other.package = git git://example.com/git/some.other.package.git
# bzr.package = bzr bzr+ssh://bazaar.launchpad.net/~user/project/branch/
python-scribd = svn http://python-scribd.googlecode.com/svn/trunk
django-annoying = hg https://bitbucket.org/sirex/django-annoying
django-sugar = git git://github.com/montylounge/django-sugar.git
django-filebrowser-no-grappelli = git git://github.com/wardi/django-filebrowser-no-grappelli.git
django-webtopay = git git://github.com/Motiejus/django-webtopay.git
[versions]
South = 0.7.3
django = 1.3
django-mptt = 0.4.2
django-pagination = 1.0.7
django-registration = 0.8
feincms = 1.4.2
mock = 0.8.0
simplejson = 2.2.1
djangorestframework = 2.2.7
markdown = 2.3.1
django-debug-toolbar = 0.9.4
[django]
recipe = djangorecipe
project = project
settings = production
eggs = ${buildout:eggs}
extra-paths = ${buildout:extra-paths}
wsgi = true
wsgilog = ${buildout:directory}/var/log/wsgi.log
[mkdir]
recipe = z3c.recipe.mkdir
paths =
${buildout:directory}/var/htdocs/static
${buildout:directory}/var/log
[apacheconf]
recipe = collective.recipe.template
input = ${buildout:directory}/etc/apache.conf.in
output = ${buildout:directory}/etc/apache.conf
[production.py]
recipe = collective.recipe.template
input = ${buildout:directory}/etc/production.py.in
output = ${buildout:directory}/etc/production.py
[my.cnf]
recipe = collective.recipe.template
input = ${buildout:directory}/etc/my.cnf.in
output = ${buildout:directory}/etc/my.cnf
[scribd-patch]
recipe = collective.recipe.patch
path = parts/python-scribd/scribd/
patches = patches/scribd-issue-3.diff
[jquery-ui]
recipe = hexagonit.recipe.download
url = http://jquery-ui.googlecode.com/files/jquery-ui-1.8.19.zip
destination = ${buildout:directory}/var/vendor-staticfiles
ignore-existing = true
excludes =
index.html
development-bundle/*
[tinymce]
recipe = hexagonit.recipe.download
url = https://github.com/tinymce/tinymce/archive/3.4.4.zip
destination = ${buildout:directory}/var/vendor-staticfiles
ignore-existing = true
excludes =
tinymce/changelog.txt
examples/*
strip-top-level-dir = true
从我看到的django.utils.text中的Truncator类不在django 1.3中。如果我不得不猜测某个模块,其版本未在buildout中指定使用此类,但在此项目是在django 1.3上构建时却没有。
我是对的吗?是否 - 我的选择是什么?
答案 0 :(得分:2)
Truncator类已添加到Django 1.4中。显然你安装的django-extension版本需要Django 1.4或更新版本;是试图进行此导入的包。
您必须找到适用于您的Django 1.3设置的该软件包的旧版本。
看看django-extensions GitHub回购,你可以在去年11月看到他们removed compatibility for older Django versions。 GitHub UI向我们显示包含该提交的最早标记是1.3,因此之前的版本应该仍然有用。根据GitHub标签列表和django-extensions PyPI information。
,该版本似乎是2.5在您的版本部分中固定该包:
[versions]
# ...
django-extensions = 1.2.5