python
config_error
ai_generated
true
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%Fix Rate
88%Confidence
0Evidence
2024-07-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
STATIC_ROOT is not configured when using collectstatic or serving static files in production.
generic中文
在使用collectstatic或生产环境中提供静态文件时,STATIC_ROOT未配置。
Workarounds
-
95% success Set STATIC_ROOT in settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
-
90% success Run collectstatic after setting
python manage.py collectstatic
Dead Ends
Common approaches that don't work:
-
Setting STATIC_ROOT to a non-existent path
80% fail
Directory must exist or be created.
-
Ignoring the setting and using STATICFILES_DIRS only
90% fail
collectstatic requires STATIC_ROOT.