python
config_error
ai_generated
true
Django配置错误:你正在使用staticfiles应用而没有设置STATIC_ROOT为文件系统路径。
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
ID: python/django-static-file-not-found
80%修复率
88%置信度
0证据数
2024-07-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
在使用collectstatic或生产环境中提供静态文件时,STATIC_ROOT未配置。
English
STATIC_ROOT is not configured when using collectstatic or serving static files in production.
解决方案
-
95% 成功率 Set STATIC_ROOT in settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
-
90% 成功率 Run collectstatic after setting
python manage.py collectstatic
无效尝试
常见但无效的做法:
-
Setting STATIC_ROOT to a non-existent path
80% 失败
Directory must exist or be created.
-
Ignoring the setting and using STATICFILES_DIRS only
90% 失败
collectstatic requires STATIC_ROOT.