问题:

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

 

查看原文