2014-04-22 21 views
38

Sono nuovo di django! Quando uso il comando python manage.py collectstatic ottengo questo erroreImpossibile eseguire collectstatic

django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path 

Ma posso eseguire correttamente il server.

mie dichiarazioni file statici sono:

STATIC_ROOT = '' 

STATIC_URL = '/static/' 


STATICFILES_DIRS = (

    ('assets', os.path.join(PROJECT_DIR, '../static')), 
) 

ed eseguire il debug è impostata su true

DEBUG = True 

Come posso risolvere questo problema? Altrove mancano i pacchetti di installazione?

+2

Cosa non capisci di questo messaggio di errore molto chiaro? Non hai impostato STATIC_ROOT su un percorso file. –

+0

heroku http://stackoverflow.com/questions/21141315/django-static-files-on-heroku –

risposta

80

Prova questo,

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

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

+0

Grazie :) Funziona! Prima stavo usando questa applicazione con root statico come vuota. Ma ha funzionato! Quale potrebbe essere il problema ora? – user3383301

+0

È necessario definire la cartella statica. Tutti i file statici vengono raccolti in tale cartella. 'Stai usando l'app staticfiles senza aver impostato l'impostazione STATIC_ROOT su un percorso del filesystem' – dhana

+0

Okayy grazie :) – user3383301

8

È necessario disporre di dare percorso nel STATIC_ROOT in settings.py dove tutti i vostri file statici vengono raccolti come ad esempio: -

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

STATIC_URL = '/static/' 

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

    ) 
Problemi correlati