Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collecting staticfiles throws ImproperlyConfigured

Tags:

django

I'm using Django 1.7. When deploying my site to a Production server and running collectstatic, I get following error message: django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting

I use split settings; my production local.py contains:

STATIC_ROOT = '/home/username/projects/site/static/' 

and my base.py contains:

STATICFILES_DIRS = (     os.path.join(BASE_DIR, 'static'), ) 
like image 959
SaeX Avatar asked Nov 30 '14 13:11

SaeX


People also ask

What is Staticfiles_dirs?

STATICFILES_DIRS is the list of folders where Django will search for additional static files aside from the static folder of each app installed.

What is Collectstatic?

collectstatic. django-admin collectstatic. Collects the static files into STATIC_ROOT . Duplicate file names are by default resolved in a similar way to how template resolution works: the file that is first found in one of the specified locations will be used.

How does django manage static files?

Configuring static filesMake sure that django.contrib.staticfiles is included in your INSTALLED_APPS . In your templates, use the static template tag to build the URL for the given relative path using the configured STATICFILES_STORAGE . Store your static files in a folder called static in your app.

Which of these variables are the settings for django contrib Staticfiles app?

staticfiles app? Explanation : All of the above are variables are the settings for django.


1 Answers

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/'

like image 78
2 revs Avatar answered Oct 06 '22 09:10

2 revs