I am new to django ! When I use the command python manage.py collectstatic
I get this error
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path
But I can successfully run the server .
My static files declarations are :
STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( ('assets', os.path.join(PROJECT_DIR, '../static')), )
and debug is set to true
DEBUG = True
How can I fix this? Else am missing any installation packages ?
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. If you're confused, the findstatic command can help show you which files are found.
Using the collectstatic command, Django looks for all static files in your apps and collects them wherever you told it to, i.e. the STATIC_ROOT . In our case, we are telling Django that when we run python manage.py collectstatic , gather all static files into a folder called staticfiles in our project root directory.
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
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'), )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With