python
data_error
ai_generated
true
django.db.utils.OperationalError: no such table: django_session
ID: python/django-session-table-missing
80%Fix Rate
84%Confidence
0Evidence
2024-04-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.2 | active | — | — | — |
| 4.0 | active | — | — | — |
Root Cause
会话表未创建,通常因为未运行 migrate
generic中文
Django 会话框架需要 django_session 表,但未通过迁移创建
Workarounds
-
100% success 运行迁移创建会话表
python manage.py migrate sessions
-
98% success 运行所有迁移
python manage.py migrate
Dead Ends
Common approaches that don't work:
-
手动创建表结构
90% fail
Django 的 ORM 需要与迁移一致,手动创建可能导致字段不匹配
-
禁用会话中间件
70% fail
会话功能完全失效,影响用户登录等