{
  "id": "python/django-foreign-key-null",
  "signature": "django.db.utils.IntegrityError: NOT NULL constraint failed: app_model.foreign_key_id",
  "signature_zh": "Django数据库完整性错误：非空约束失败：app_model.foreign_key_id",
  "regex": "django\\.db\\.utils\\.IntegrityError:\\ NOT\\ NULL\\ constraint\\ failed:\\ app_model\\.foreign_key_id",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Attempting to save a model instance without a required foreign key value.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试保存模型实例，但缺少必填的外键值。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "0 typically doesn't exist, causing integrity errors or wrong references.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Breaks data integrity and business logic.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure the related object is created first and assign it: obj.foreign_key = related_obj; obj.save()",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}