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

Viewed 6084

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 Answers

It was removed from Django 4, use this instead

from django.utils.translation import gettext_lazy as _
Related