{
  "id": "python/django-orm-delete-error",
  "signature": "django.db.models.deletion.ProtectedError: Cannot delete some instances of model 'Author' because they are referenced through protected foreign keys: 'Article.author'",
  "signature_zh": "删除保护错误：无法删除'Author'的某些实例，因为它们通过受保护的外键'Article.author'被引用",
  "regex": "django\\.db\\.models\\.deletion\\.ProtectedError:\\ Cannot\\ delete\\ some\\ instances\\ of\\ model\\ 'Author'\\ because\\ they\\ are\\ referenced\\ through\\ protected\\ foreign\\ keys:\\ 'Article\\.author'",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "尝试删除被外键引用的对象，且外键设置了PROTECT",
  "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": "Django ORM没有force_delete方法，会破坏数据完整性",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "删除操作无法完成",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "article.delete() 然后 author.delete()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在模型中设置on_delete=models.CASCADE",
      "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-10-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}