[Django]-Unable to perform collectstatic

176👍

Try this,

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

Look at https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATIC_ROOT

👤dhana

10👍

You must have to give path in STATIC_ROOT in settings.py where all your static files are collected as for example:-

STATIC_ROOT = "app-root/repo/wsgi/static"

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    ('assets', 'app-root/repo/wsgi/openshift/static'),

    )

3👍

you can create ‘static’ folder in any subfolder and have required files in it.
In settings.py add the following lines of code:

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
STATIC_URL = '/static/'

After running
python manage.py collectstatic
a new static folder will be created in your parent App folder

2👍

well had this error as well. I fixed:

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

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

1👍

I had to put STATIC_ROOT and STATIC_URL above the STATICFILES_DIRS declaration.

1👍

STATIC_ROOT = os.path.join(BASE_DIR, 'assest')
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'static')
]

0👍

STATIC_ROOT = "/var/www/YourSiteFolder/static/"
STATIC_URL = '/static/'

look at https://docs.djangoproject.com/en/1.11/howto/static-files/#deployment

0👍

STATIC_URL = ‘/static/’

STATIC_ROOT = os.path.join(BASE_DIR,’static’)

This works for me

enter image description here

0👍

if you want to load static files rather than admin panel files or getting errors while loading webpage static files like CSS js etc

I suggest you change the folder name of ‘static‘ to ‘staticfiles

and then add this code in your settings.py

STATICFILES_DIRS = (
os.path.join(BASE_DIR, ‘staticfiles’),
)

then after run python manage.py collectstatic

Then the problem will be fixed

enter image description here

Leave a comment