Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRUDHistoryAdminMixin does not support Django 4 #322

Open
hydrospanner opened this issue Jan 15, 2025 · 0 comments · May be fixed by #323
Open

CRUDHistoryAdminMixin does not support Django 4 #322

hydrospanner opened this issue Jan 15, 2025 · 0 comments · May be fixed by #323

Comments

@hydrospanner
Copy link

hydrospanner commented Jan 15, 2025

  1. What version of Python and Django are you using?

Python: 3.12.3
Django: 4.2.11

  1. What operating system and processor architecture are you using?
    Ubuntu 24.04.1 LTS
    x86_64

  2. What did you do?
    Import the CRUDHistoryAdminMixin to use in a ModelAdmin class.

from easyaudit.crudhistory_admin_mixin import CRUDHistoryAdminMixin
  1. What did you expect to see?
    An import without errors.

  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant