{
  "id": "python/django-middleware-type-error",
  "signature": "TypeError: __init__() missing 1 required positional argument: 'get_response'",
  "signature_zh": "类型错误：__init__()缺少1个必需的位置参数：'get_response'",
  "regex": "TypeError:\\ __init__\\(\\)\\ missing\\ 1\\ required\\ positional\\ argument:\\ 'get_response'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Custom middleware class does not accept the get_response argument in __init__.",
  "root_cause_type": "generic",
  "root_cause_zh": "自定义中间件类的__init__方法没有接受get_response参数。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Omitting __init__ method",
      "why_fails": "Django middleware requires get_response.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using wrong signature",
      "why_fails": "Must match exactly.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define __init__ with get_response",
      "success_rate": 0.95,
      "how": "class MyMiddleware:\n    def __init__(self, get_response):\n        self.get_response = get_response",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use MiddlewareMixin",
      "success_rate": 0.9,
      "how": "from django.utils.deprecation import MiddlewareMixin\nclass MyMiddleware(MiddlewareMixin): ...",
      "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-07-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}