Calling any of ugettext(), ugettext_lazy(), ugettext_noop(), ungettext()
and ungettext_lazy()
functions from django.utils.translation
will raise a RemovedInDjango40Warning
deprecation warning.
python -Wall manage.py runserver
/Users/stormh/torchbox/wagtail/wagtail/admin/edit_handlers.py:762: RemovedInDjango40Warning: django.utils.translation.ugettext_lazy() is deprecated in favor of django.utils.translation.gettext_lazy().
'heading': ugettext_lazy('Scheduled publishing'),
ugettext
functions have been deprecated in Django 3.0
The reason for the deprecation is that these are legacy aliases for their corresponding gettext
counterparts. They were once used for unicode compatibility with Python 2.7 according to this ticket
We should replace all references to ugettext
functions with their gettext
counterparts. This should have no negative influence because Wagtail does not support Python 2.7 anymore and this change would be compatible with Django 2.2 LTS.
Now, do we have to hurry implementing this change? No, not really. The ugettext
functions are scheduled to be removed in Django 4.0. Which is scheduled to be released in 2022 according to this chart I took from https://www.djangoproject.com/download/
It would however be nice to get rid of those nasty deprecation warnings for that my-project-is-fully-up-to-date experience 👌
Is there any way to silence this warning until it's resolved?
@danihodovic Depends on your use case, this is how you hide them when running pytest.
[pytest]
filterwarnings =
ignore::django.utils.deprecation.RemovedInDjango40Warning
Thank you @marteinn !
Completed in #5907, but since it's entirely possible that new occurrences may sneak in as a result of merging existing PRs, I'll leave this open to remind us to do another sweep before the 2.9 release.
Re-checked, and no new occurrences have crept in, so I think we're all good 👍
Most helpful comment
@danihodovic Depends on your use case, this is how you hide them when running pytest.