Django4.0 ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation'

12.9k Views Asked by At

I use translation in my Django apps. Since I installed Django version 4, when I try to import ugettexget_lazy as shown in the code below

from django.utils.translation import ugettexget_lazy as _

I get the following error:

ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation'
1

There are 1 best solutions below

1
On BEST ANSWER

It was removed from Django 4, use this instead

from django.utils.translation import gettext_lazy as _