【发布时间】:2019-07-18 15:57:34
【问题描述】:
我正在更新一个非常旧的 Django 项目并尝试使用 RegistrationSupplementBase,但在导入时我收到以下错误消息:
File "/home/projectmachine/Desktop/project_rebuild/projectname/models.py", line 11, in <module>
from registration.supplements.base import RegistrationSupplementBase
File "/home/projectmachine/.local/share/virtualenvs/projectname-QrYA9Qp-/lib/python3.6/site-packages/registration/supplements/base.py", line 9, in <module>
from django.utils.text import ugettext_lazy as _
ImportError: cannot import name 'ugettext_lazy'
我不知道出了什么问题。安装的依赖项似乎存在问题。我正在使用 Django 2.2 和 django-inspectional-registration 0.6.2
这是我导入类的方式:
from registration.supplements.base import RegistrationSupplementBase
【问题讨论】:
-
这些已移至
django.utils.translation。但无论如何,这些都被贬低了。你应该用from django.utils.translation import gettext_lazy as _替换它。 -
在这种情况下,错误来自 django-inspectional-registration。看起来它有not been updated 好几年了,所以它不支持最新版本的 Django。您可以尝试分叉代码并进行 Willem 建议的更改,但我怀疑需要进行其他更改才能使其与 Django 2.2 一起使用。
标签: python django python-3.6 django-registration