question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use of uggettext functions is deprecated

See original GitHub issue

Issue 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

  1. Start the development server with warnings enabled for a Wagtail project with Django 3.0 installed: python -Wall manage.py runserver
  2. 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
marteinncommented, Mar 1, 2020

@danihodovic Depends on your use case, this is how you hide them when running pytest.

[pytest]
filterwarnings =
    ignore::django.utils.deprecation.RemovedInDjango40Warning
1reaction
gasmancommented, Apr 2, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

30165 (Deprecate ugettext(), ugettext_lazy(), ugettext_noop ...
As other compatibility layers have been cleaned up, these shims can be deprecated for removal. Oldest first. Newest first. Threaded. Show comments
Read more >
ImportError : cannot import name 'ugettext_lazy' - Stack Overflow
'ugettext_lazy' seems to be used by the app you are trying to use as well. 'ugettext_lazy' has been deprecated for django 3+ so...
Read more >
Django 3.0 release notes
We've dropped some features that have reached the end of their deprecation cycle, and we've begun the deprecation process for some features.
Read more >
Issue 33710: Deprecate gettext.lgettext() - Python tracker
In Python 3 gettext.gettext() was removed, and gettext.ugettext() was renamed to ... What's the process for deprecating functions?
Read more >
Django Tips #18 Difference Between ugettext And ugettext_lazy
The Django translation API provides several utility functions to help you translate your application. They are allavailable in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found