{
  "id": "python/django-file-upload-error",
  "signature": "django.core.exceptions.ValidationError: [\"Upload a valid image. The file you uploaded was either not an image or a corrupted image.\"]",
  "signature_zh": "验证错误：[\"上传有效的图片。您上传的文件不是图片或已损坏。\"]",
  "regex": "django\\.core\\.exceptions\\.ValidationError:\\ \\[\"Upload\\ a\\ valid\\ image\\.\\ The\\ file\\ you\\ uploaded\\ was\\ either\\ not\\ an\\ image\\ or\\ a\\ corrupted\\ image\\.\"\\]",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "上传的文件不是有效的图片格式或已损坏",
  "root_cause_type": "generic",
  "root_cause_zh": "ImageField验证失败，文件内容不符合图片格式要求",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Django检查文件内容而非扩展名",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "只影响内存使用，不影响文件验证",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "使用PIL库验证图片：from PIL import Image; Image.open(file).verify()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "model字段改为FileField(upload_to='uploads/')",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}