我当前正被该错误所困扰:
dictionary update sequence element #0 has length 14; 2 is required
似乎由('SessionStore' object has no attribute '_session_cache')
激怒了
我读到了一个问题:Django project looking for "attribute '_session_cache'",问题可能是我没有django_session
表,但是我有,并且里面充满了内容。
有什么想法会引起这种情况吗?
我在使用Python 3.6.7
,Django 2.1.7
这是完整的错误堆栈:
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py" in _get_session
190. return self._session_cache
During handling of the above exception ('SessionStore' object has no attribute '_session_cache'), another exception occurred:
File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/path/to/venv/lib/python3.6/site-packages/django/utils/deprecation.py" in __call__
90. response = self.process_request(request)
File "/path/to/venv/lib/python3.6/site-packages/django/middleware/locale.py" in process_request
21. language = translation.get_language_from_request(request, check_path=i18n_patterns_used)
File "/path/to/venv/lib/python3.6/site-packages/django/utils/translation/__init__.py" in get_language_from_request
222. return _trans.get_language_from_request(request, check_path)
File "/path/to/venv/lib/python3.6/site-packages/django/utils/translation/trans_real.py" in get_language_from_request
464. lang_code = request.session.get(LANGUAGE_SESSION_KEY)
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py" in get
66. return self._session.get(key, default)
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py" in _get_session
195. self._session_cache = self.load()
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py" in load
43. s = self._get_session_from_db()
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py" in _get_session_from_db
34. expire_date__gt=timezone.now()
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
390. clone = self.filter(*args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in filter
844. return self._filter_or_exclude(False, *args, **kwargs)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
862. clone.query.add_q(Q(*args, **kwargs))
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
1263. clause, _ = self._add_q(q_object, self.used_aliases)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
1289. joinpromoter.add_votes(needed_inner)
File "/path/to/venv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_votes
2171. self.votes.update(votes)
File "/usr/lib/python3.6/collections/__init__.py" in update
620. super(Counter, self).update(iterable) # fast path when counter is empty
Exception Type: ValueError
Exception Value: dictionary update sequence element #0 has length 14; 2 is required
答案 0 :(得分:2)
当尝试将Django 3.1降级为Django 2.2时,我遇到了同样的问题。
问题也在此处跟踪: https://code.djangoproject.com/ticket/31592
从上方链接:
# To fix this you need to remove sessions from cache, e.g.
from django.contrib.sessions.models import Session
Session.objects.all().delete()
答案 1 :(得分:0)
也许当您卸载某些软件包时。检查您的设置文件是否为MIDDLEWARE_CLASSES中的“ django.contrib.sessions.middleware.SessionMiddleware”。
或
有时只是放在控制台上: python manage.py migration ,它又重新存在