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

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-07-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

STATIC_ROOT is not configured when using collectstatic or serving static files in production.

generic

中文

在使用collectstatic或生产环境中提供静态文件时,STATIC_ROOT未配置。

Workarounds

  1. 95% success Set STATIC_ROOT in settings.py
    STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  2. 90% success Run collectstatic after setting
    python manage.py collectstatic

Dead Ends

Common approaches that don't work:

  1. Setting STATIC_ROOT to a non-existent path 80% fail

    Directory must exist or be created.

  2. Ignoring the setting and using STATICFILES_DIRS only 90% fail

    collectstatic requires STATIC_ROOT.