Python RegistrationSupplementBase 的 Django 导入错误无法导入名称 'ugettext_lazy'
Python with Django Import error with RegistrationSupplementBase cannot import name 'ugettext_lazy'
我正在更新一个非常旧的 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
这是我导入 class:
的方式
from registration.supplements.base import RegistrationSupplementBase
I can't figure out what's wrong. It seems like there is an issue with the dependancies installed. I'm using Django 2.2 with django-inspectional-registration
0.6.2
该函数已移至 django.utils.translation
模块,因此您可以通过以下方式导入:
from <b>django.utils.translation</b> import ugettext_lazy as _
基于Django Deprecation Timeline [Django-doc], ugettext_lazy
will be removed in django-4.0。您可以使用 gettext_lazy
代替:
from django.utils.translation import <b>gettext_lazy</b> as _
然而,基于 GitHub repository of django-inspectional-registration
,该项目不再活跃:最新提交是在 2016 年 11 月。您可以尝试更新该项目,但也许最好寻找一个替代包以类似的方式工作。
我正在更新一个非常旧的 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
这是我导入 class:
的方式from registration.supplements.base import RegistrationSupplementBase
I can't figure out what's wrong. It seems like there is an issue with the dependancies installed. I'm using Django 2.2 with
django-inspectional-registration
0.6.2
该函数已移至 django.utils.translation
模块,因此您可以通过以下方式导入:
from <b>django.utils.translation</b> import ugettext_lazy as _
基于Django Deprecation Timeline [Django-doc], ugettext_lazy
will be removed in django-4.0。您可以使用 gettext_lazy
代替:
from django.utils.translation import <b>gettext_lazy</b> as _
然而,基于 GitHub repository of django-inspectional-registration
,该项目不再活跃:最新提交是在 2016 年 11 月。您可以尝试更新该项目,但也许最好寻找一个替代包以类似的方式工作。