当前位置 : 主页 > 手机开发 > harmonyos >

cannot import name 'ugettext_lazy' from 'django.utils.translation'

来源:互联网 收集:自由互联 发布时间:2023-10-08
问题: from django.utils.translation import ugettext_lazy as _ ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (C:\Python38\lib\site-packages\django\utils\translation\__init__.py) 解决方法: 采用低版

问题:

from django.utils.translation import ugettext_lazy as _
ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (C:\Python38\lib\site-packages\django\utils\translation\__init__.py)

 

解决方法:

采用低版本的Django,比如 Django 2.X

 

==============================

'ugettext_lazy' has been deprecated for django 3+ so you won’t be able to use that with a django version >= 3. https://code.djangoproject.com/ticket/30165

==============================

One answer is ugettext_lazy has been removed in Django 4.0 57. Please use gettext_lazy instead ""

from django.utils.translation import gettext_lazy as _

 

==============================

 

I have solved the problem by installing the django==3.2 instead of the latest version of Django. But I`ll still check for the pypi update for the usage in the latest version of Django.

==============================

 

 

REF

https://stackoverflow.com/questions/70656495/importerror-cannot-import-name-ugettext-lazy

 



上一篇:Django 4.0 入门系列 目录
下一篇:没有了
网友评论