8

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'
Gedeon Mutshipayi
  • 2,871
  • 3
  • 21
  • 42

1 Answers1

17

It was removed from Django 4, use this instead

from django.utils.translation import gettext_lazy as _
PTomasz
  • 1,330
  • 1
  • 7
  • 23
  • a batter solution is 1. replacing the requirement django-jsonfield==1.4.1 with django-jsonfield-backport==1.0.5 2. adding django-jsonfield-backport in settings to installed apps 3. replacing the import in our model file from from jsonfield import JSONField to from django.db.models import JSONField 4. rebuilding the migration files – Macilias May 18 '22 at 18:17