{
  "id": "python/django-foreign-key-null-error",
  "signature": "django.db.utils.IntegrityError: NOT NULL constraint failed: myapp_order.user_id",
  "signature_zh": "django.db.utils.IntegrityError: 非空约束失败：myapp_order.user_id",
  "regex": "django\\.db\\.utils\\.IntegrityError:\\ NOT\\ NULL\\ constraint\\ failed:\\ myapp_order\\.user_id",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Trying to save an object with a ForeignKey field set to None, but the field is not nullable.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试保存ForeignKey字段为None的对象，但该字段不可为空。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Allows null values, but may not be intended and can cause data integrity issues.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Silently fails, data not saved, and may cause inconsistencies.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure the ForeignKey is set before saving: order.user = request.user",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use get_or_create to handle missing related objects.",
      "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-11-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}