{
  "id": "python/django-ajax-csrf-error",
  "signature": "Forbidden (CSRF cookie not set.): /api/update/",
  "signature_zh": "禁止访问（CSRF cookie 未设置）：/api/update/",
  "regex": "Forbidden\\ \\(CSRF\\ cookie\\ not\\ set\\.\\):\\ /api/update/",
  "domain": "python",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "AJAX request does not include CSRF token in headers or cookie is missing.",
  "root_cause_type": "generic",
  "root_cause_zh": "AJAX 请求未在标头中包含 CSRF 令牌，或 cookie 缺失。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding @csrf_exempt to view bypasses security, not recommended.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hardcoding CSRF token in JavaScript doesn't work as it changes per session.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure CSRF cookie is set by using {% csrf_token %} in template, then include token in AJAX: headers: {'X-CSRFToken': getCookie('csrftoken')}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use Django's ensure_csrf_cookie decorator on the view that returns the page.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-02-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}