Skip to content
Latchkey

Django collectstatic "you're using the staticfiles app without having set STATIC_ROOT" in CI

collectstatic copies static assets into STATIC_ROOT, but the active settings did not define it. Django refuses to run the command without a target directory and raises ImproperlyConfigured.

What this error means

A python manage.py collectstatic --noinput build step fails with "ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path."

python
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app
without having set the STATIC_ROOT setting to a filesystem path.

Common causes

STATIC_ROOT is undefined in the CI settings

A test or CI settings module omits STATIC_ROOT, so collectstatic has nowhere to write.

Wrong settings module for the build step

DJANGO_SETTINGS_MODULE points at a module that does not configure staticfiles for production-style collection.

How to fix it

Set STATIC_ROOT to a build path

Define an absolute path for collected files in the settings the build uses.

settings.py
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_ROOT = BASE_DIR / "staticfiles"

Point the step at the right settings

Run collectstatic with the settings module that configures staticfiles.

Terminal
python manage.py collectstatic --noinput \
  --settings=myproject.settings.production

How to prevent it

  • Define STATIC_ROOT in any settings module used to build assets.
  • Pick the correct DJANGO_SETTINGS_MODULE for each CI stage.
  • Run collectstatic with --noinput so it never blocks on a prompt.

Frequently asked questions

What causes ""without having set the STATIC_ROOT setting""?
A test or CI settings module omits STATIC_ROOT, so collectstatic has nowhere to write.
How do I fix "without having set the STATIC_ROOT setting"?
Define an absolute path for collected files in the settings the build uses.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card