Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to perform collectstatic

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 ?

like image 608
user3383301 Avatar asked Apr 22 '14 09:04

user3383301


People also ask

Why do we need Collectstatic?

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.

How do I run Collectstatic in Django?

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.


2 Answers

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

like image 172
dhana Avatar answered Oct 03 '22 10:10

dhana


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'),      ) 
like image 28
Sheesh Mohsin Avatar answered Oct 03 '22 11:10

Sheesh Mohsin