无法执行collectstatic

use*_*301 59 python django django-staticfiles

我是django的新手!当我使用命令时,python manage.py collectstatic我收到此错误

django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path
Run Code Online (Sandbox Code Playgroud)

但我可以成功运行服务器.

我的静态文件声明是:

STATIC_ROOT = ''

STATIC_URL = '/static/'


STATICFILES_DIRS = (

    ('assets', os.path.join(PROJECT_DIR, '../static')),
)
Run Code Online (Sandbox Code Playgroud)

和debug设置为true

DEBUG = True
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?否则我错过任何安装包?

dha*_*ana 126

试试这个,

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
Run Code Online (Sandbox Code Playgroud)

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


She*_*sin 9

您必须在settings.py中的STATIC_ROOT中提供路径,其中收集所有静态文件,例如: -

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

STATIC_URL = '/static/'

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

    )
Run Code Online (Sandbox Code Playgroud)