Guides / ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting

ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting

You ran collectstatic (or deployed) and got ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. Django has nowhere to copy your static files to. Set STATIC_ROOT and run it again.

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

What it means

collectstatic gathers the static files of every installed app, plus your STATICFILES_DIRS, into a single folder so a web server can serve them. That folder is STATIC_ROOT. It is empty by default because Django can't guess where on your server it is safe to write. The same error appears when something else asks for the folder, such as a manifest storage backend.

This is the same root cause as Django static files not loading in production, hit one step earlier: there the files are missing at runtime, here the command that would collect them can't start.

Why it happens

  1. You never set it. startproject sets STATIC_URL but not STATIC_ROOT, because you don't need it with runserver.
  2. It is set only in a different settings file. You added it to production.py but the command runs with DJANGO_SETTINGS_MODULE pointing at base.py or local.py, or the other way around.
  3. It is read from an environment variable that is not set during the build. The build step has no STATIC_ROOT and the setting ends up empty.

The fix

# settings.py
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
python manage.py collectstatic --noinput

Use a folder that your project owns and that is not one of your source folders. Two mistakes cause the next error in line:

Then make something serve the folder. The simplest option is WhiteNoise, covered step by step in the static files guide.

Making it stick in production

Or skip it

Django Cloud runs collectstatic during every build and serves the result with WhiteNoise, unless your settings already serve static files another way, so there is no STATIC_ROOT step to forget.

pip install djangocloud-cli
djangocloud deploy

Get startedSee pricing

Free plans are available for students, AWS Activate startups, open-source, non-profit and research projects. See how Django Cloud compares with other ways to host Django.

Django is a registered trademark of the Django Software Foundation. Django Cloud is not affiliated with or endorsed by it. Found a mistake in this guide? Tell us and we will fix it.