{
  "id": "python/django-middleware-order-error",
  "signature": "django.core.exceptions.ImproperlyConfigured: CSRF middleware must be placed before any view middleware that uses CSRF token.",
  "signature_zh": "配置错误：CSRF中间件必须放在任何使用CSRF令牌的视图中间件之前",
  "regex": "django\\.core\\.exceptions\\.ImproperlyConfigured:\\ CSRF\\ middleware\\ must\\ be\\ placed\\ before\\ any\\ view\\ middleware\\ that\\ uses\\ CSRF\\ token\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "MIDDLEWARE设置中CSRF中间件顺序错误",
  "root_cause_type": "generic",
  "root_cause_zh": "settings.py中的MIDDLEWARE列表顺序不正确，CSRF中间件未在适当位置",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "会导致CSRF保护失效，存在安全风险",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "顺序错误，无法正确设置CSRF令牌",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "确保'django.middleware.csrf.CsrfViewMiddleware'在SessionMiddleware之后",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "从Django项目模板复制默认MIDDLEWARE设置",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}