Use of uggettext functions is deprecated
See original GitHub issueIssue Summary
Calling any of ugettext(), ugettext_lazy(), ugettext_noop(), ungettext()
and ungettext_lazy()
functions from django.utils.translation
will raise a RemovedInDjango40Warning
deprecation warning.
Steps to Reproduce
- Start the development server with warnings enabled for a Wagtail project with Django 3.0 installed:
python -Wall manage.py runserver
- Observe the output. It will output dozens of warnings similar to this one:
/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'),
- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes
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
How do we solve this?
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 👌
Technical details
- Python version: 3.8.1
- Django version: 3.0.3
- Wagtail version: 2.9a0
- Browser version: n/a
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top GitHub Comments
@danihodovic Depends on your use case, this is how you hide them when running pytest.
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.