[BUG] Django 4.0 removed django.utils.encoding.smart_text
darkpixel opened this issue · 6 comments
darkpixel commented
Is there an existing issue for this?
- I have searched the existing issues
Does this issue exist in the latest version?
- I'm using the latest release
Describe the bug?
Failure to load in a Django 4.x project due to the deprecated (and now-removed) smart_text alias in django.utils.encoding.
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/--redacted--/lib/python3.8/site-packages/django/utils/encoding.py)
To Reproduce
pip install django-views-breadcrumbs
- Add views_breadcrumbs to settings.py
python manage.py runserver
What OS are you seeing the problem on?
ubuntu-latest or ubuntu-20.04
Expected behavior?
I would expect the app to not crash
Relevant log output
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/--redacted--/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/--redacted--/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 115, in inner_run
autoreload.raise_last_exception()
File "/--redacted--/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/--redacted--/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute
autoreload.check_errors(django.setup)()
File "/--redacted--/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/--redacted--/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/--redacted--/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/--redacted--/lib/python3.8/site-packages/django/apps/config.py", line 223, in create
import_module(entry)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/--redacted--/lib/python3.8/site-packages/view_breadcrumbs/__init__.py", line 7, in <module>
from .generic import (
File "/--redacted--/lib/python3.8/site-packages/view_breadcrumbs/generic/__init__.py", line 1, in <module>
from .base import BaseBreadcrumbMixin # noqa
File "/--redacted--/lib/python3.8/site-packages/view_breadcrumbs/generic/base.py", line 14, in <module>
from ..templatetags.view_breadcrumbs import (
File "/--redacted--/lib/python3.8/site-packages/view_breadcrumbs/templatetags/view_breadcrumbs.py", line 18, in <module>
from django.utils.encoding import smart_text
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/--redacted--/lib/python3.8/site-packages/django/utils/encoding.py)
Anything else?
Per Django 3.x release notes (https://docs.djangoproject.com/en/4.0/releases/3.0/#deprecated-features-3-0):
Features deprecated in 3.0¶
django.utils.encoding.force_text() and smart_text()¶
The smart_text() and force_text() aliases (since Django 2.0) of smart_str() and force_str() are deprecated. Ignore this deprecation if your code supports Python 2 as the behavior of smart_str() and force_str() is different there.
Per the Django 4.x release notes (https://docs.djangoproject.com/en/4.0/releases/4.0/#features-removed-in-4-0):
django.utils.encoding.force_text() and smart_text() are removed.
Code of Conduct
- I agree to follow this project's Code of Conduct
github-actions commented
Thanks for reporting this issue.
jackton1 commented
@darkpixel Sorry for the delay but this should be resolved in the latest version v2.2.5
darkpixel commented
jackton1 commented
No worries