Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用whitenoise在cpanel中提供文件后未加载Django静态文件_Python_Django - Fatal编程技术网

Python 使用whitenoise在cpanel中提供文件后未加载Django静态文件

Python 使用whitenoise在cpanel中提供文件后未加载Django静态文件,python,django,Python,Django,我尝试使用whitenoise为静态文件提供服务,但仍然没有在页面中加载任何css/js 启用whitenoise后,我运行了collectstatic,并生成了静态文件夹 我试着两者都用 STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 以及django的存储后端 这是我的设置 INSTALLED_APPS = [ 'django.contrib.auth', 'dj

我尝试使用whitenoise为静态文件提供服务,但仍然没有在页面中加载任何css/js

启用whitenoise后,我运行了collectstatic,并生成了静态文件夹

我试着两者都用

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
以及django的存储后端

这是我的设置

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    'django.contrib.humanize',

    'crispy_forms',

    'classroom',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'django_school.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates')
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'django_school.wsgi.application'
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'public/static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
这就是我的项目的结构

home
-->etc
-->thegradientboostmvp
---->classroom
---->django-app
---->public
       >static
          >admin
          >css
          >img
          >vendor
          >second
          >third
          >fourth
---->static
------>admin
------>css
------>img
------>second
           >css
           >js
           >img
------>third
           >css
           >js
           >img
------>fourth
           >img
           >js
           >css
---->templates

在我的例子中,将我的
static
文件夹放入
public\u html
已解决。

STATICFILES\u DIRS=[os.path.join(BASE\u DIR,'static')]试试这个way@bmons我试过了,可惜不行