Collecting staticfiles throws ImproperlyConfigured

The solution is that the STATIC_ROOT must not be set if you are running the Django development server:

import sys
if sys.argv[1] != 'runserver':
    STATIC_ROOT = os.path.join(BASE_DIR, "static")

Tested with Django 2.1 in a Windows 10 development environment and in an Ubuntu 18.04 docker container on AWS in a production environment.


I know it is an old post but this solution has worked for me and might help someone else.

In settings.py:

    if DEBUG:
        STATICFILES_DIRS = [
            os.path.join(BASE_DIR, 'static')
       ]
    else:
        STATIC_ROOT = os.path.join(BASE_DIR, 'static')

According to the docs, collectstatic will copy the files from various folders into STATIC_ROOT.

Therefore, you cannot use the STATIC_ROOT folder in STATICFILES_DIRS.

Solution: change STATIC_ROOT to e.g. STATIC_ROOT = '/home/username/projects/site/assets/'


I faced same error like this (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting. when i try to use compressor

Main problem is My settings.py file

STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]

Remove or comment :

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]

Tags:

Django