Django 4.0.1 无法导入名称“SortedDict”来自“django.utils.datastructs”

发布于 2025-01-17 00:00:53 字数 3013 浏览 4 评论 0原文

我的项目无法运行!我需要帮助!

我只是填写表格。然后单击登录按钮。错误:

Traceback (most recent call last):
  File "/home/pc/.local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/pc/.local/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/pc/Documents/Projects/Django/Travel/Web/views.py", line 92, in sign_in
    user = auth.authenticate(username=username, password=password)
  File "/home/pc/.local/lib/python3.10/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper
    return func(*func_args, **func_kwargs)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/__init__.py", line 77, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/backends.py", line 48, in authenticate
    if user.check_password(password) and self.user_can_authenticate(user):
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 115, in check_password
    return check_password(raw_password, self.password, setter)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 47, in check_password
    preferred = get_hasher(preferred)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 129, in get_hasher
    return get_hashers()[0]
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 96, in get_hashers
    hasher_cls = import_string(hasher_path)
  File "/home/pc/.local/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/home/pc/.local/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/pc/.local/lib/python3.10/site-packages/django_scrypt/hashers.py", line 2, in <module>
    from django.utils.datastructures import SortedDict
ImportError: cannot import name 'SortedDict' from 'django.utils.datastructures' (/home/pc/.local/lib/python3.10/site-packages/django/utils/datastructures.py)

任何人都可以帮助我吗?我尝试了很多次。但什么也没发生!

My project isn't working! I need help!

I'm just fill in the forms. And click login button. Error:

Traceback (most recent call last):
  File "/home/pc/.local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/pc/.local/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/pc/Documents/Projects/Django/Travel/Web/views.py", line 92, in sign_in
    user = auth.authenticate(username=username, password=password)
  File "/home/pc/.local/lib/python3.10/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper
    return func(*func_args, **func_kwargs)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/__init__.py", line 77, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/backends.py", line 48, in authenticate
    if user.check_password(password) and self.user_can_authenticate(user):
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 115, in check_password
    return check_password(raw_password, self.password, setter)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 47, in check_password
    preferred = get_hasher(preferred)
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 129, in get_hasher
    return get_hashers()[0]
  File "/home/pc/.local/lib/python3.10/site-packages/django/contrib/auth/hashers.py", line 96, in get_hashers
    hasher_cls = import_string(hasher_path)
  File "/home/pc/.local/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/home/pc/.local/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/pc/.local/lib/python3.10/site-packages/django_scrypt/hashers.py", line 2, in <module>
    from django.utils.datastructures import SortedDict
ImportError: cannot import name 'SortedDict' from 'django.utils.datastructures' (/home/pc/.local/lib/python3.10/site-packages/django/utils/datastructures.py)

Anyone can help me? I tried many times. But nothing happened!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

々眼睛长脚气 2025-01-24 00:00:53

SortedDict 从 Django 1.7 开始已弃用,并在 Django 1.9 中删除。使用collections.OrderedDict代替

from collections import OrderedDict

SortedDict is deprecated as of Django 1.7 and removed in Django 1.9. Use ​collections.OrderedDict instead

from collections import OrderedDict
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文