- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前收到以下错误的垃圾邮件: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
最佳答案
在尝试将 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()
关于python - Django 'SessionStore' 对象没有属性 '_session_cache',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54722170/
我目前收到以下错误的垃圾邮件: dictionary update sequence element #0 has length 14; 2 is required这似乎是由 ('SessionSto
所以我有一个不使用数据库的 Django 项目('DATABASES' 设置被注释掉了)。我选择使用 Django,因为将来我可能会需要数据库功能。无论如何,我已经在 tbhis 项目上断断续续地工作
我是一名优秀的程序员,十分优秀!