我想用django-modeltranslation翻译我的模型字段的内容。
当我运行其中一个时:
python manage.py makemigrations
python manage.py runserver
我得到ImportError:无法导入名称'Constraint'
以下是'makemigrations'的追溯
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 324, in execute
django.setup()
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/modeltranslation/admin.py", line 20, in <module>
from modeltranslation.translator import translator
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/modeltranslation/translator.py", line 12, in <module>
from modeltranslation.manager import (MultilingualManager, MultilingualQuerysetManager,
File "/home/mat/Desktop/python/pmm/venv/lib/python3.4/site-packages/modeltranslation/manager.py", line 19, in <module>
from django.db.models.sql.where import Constraint
ImportError: cannot import name 'Constraint'
我使用django1.9和最新的django-modeltranslation。
如果您无法帮我解决错误,请推荐任何其他型号翻译应用。
我遇到过其中一些:
但他们似乎不再支持了。你知道这些是否有效,或者你知道其他任何有效的解决方案吗?
如果重要,我必须承认我使用django-rosette
答案 0 :(得分:1)
我找到了其他模型翻译应用django-hvad。
像魅力一样,有完整的django1.9支持,易于实现,并且对翻译友好。
答案 1 :(得分:0)
您确定使用的是最新的django-modeltranslation吗?该问题已在不久前报道过(https://github.com/deschler/django-modeltranslation/issues/349),已在版本0.11rc1(https://pypi.python.org/pypi/django-modeltranslation/0.11rc1)中修复。