-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
- What version of Python and Django are you using?
Python: 3.12.3
Django: 4.2.11
-
What operating system and processor architecture are you using?
Ubuntu 24.04.1 LTS
x86_64 -
What did you do?
Import theCRUDHistoryAdminMixin
to use in a ModelAdmin class.
from easyaudit.crudhistory_admin_mixin import CRUDHistoryAdminMixin
-
What did you expect to see?
An import without errors. -
What did you see instead?
Importing the Mixin is raising an ImportError because it uses ugettext_lazy
which was removed in Django 4.0, replaced with gettext_lazy
.
To replicate the issue in this project, if the above import is added to tests/test_main.py
, pytest will output:
_____________________ ERROR collecting tests/test_main.py ______________________
ImportError while importing test module '/home/jt/code/django-easy-audit/tests/test_main.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_main.py:13: in <module>
from easyaudit.crudhistory_admin_mixin import CRUDHistoryAdminMixin
easyaudit/crudhistory_admin_mixin.py:11: in <module>
from django.utils.translation import ugettext_lazy as _
E ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/home/jt/code/django-easy-audit/.venv/lib/python3.12/site-packages/django/utils/translation/__init__.py)
The fix is as simple as updating the function name in this line to gettext_lazy
.
For reference, this PR added the feature.
Metadata
Metadata
Assignees
Labels
No labels