python config_error ai_generated true

django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.

ID: python/django-staticfile-notfound

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The STATICFILES_DIRS list includes the same path as STATIC_ROOT, causing a configuration conflict.

generic

中文

STATICFILES_DIRS列表包含了与STATIC_ROOT相同的路径,导致配置冲突。

Workarounds

  1. 95% success
    Ensure STATIC_ROOT and STATICFILES_DIRS point to different directories. Example: STATIC_ROOT = BASE_DIR / 'staticfiles' and STATICFILES_DIRS = [BASE_DIR / 'static']

Dead Ends

Common approaches that don't work:

  1. 50% fail

    STATIC_ROOT is required for collectstatic to work in production.

  2. 40% fail

    Loses custom static file locations, breaking app-specific static files.