我使用whitenoise在Django项目中提供静态文件。这是settings.py
STATIC_URL = 'data/static/'
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'data/static/'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')我的静态文件在data/static文件夹中。当我在注释这一行之后尝试运行python manage.py collectstatic时:
STATICFILES_STORAGE = 'whitenoise.storage.CompressedMainfestStaticFilesStorage'运行的很好。但是,当我试图在取消注释后运行collectstatic时,它会出现上述错误。有人知道为什么这是个错误吗?
下面是应用程序和中间件:
INSTALLED_APPS = [
'admin_interface',
'colorfield',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'app',
]
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',
]我已经尝试过将Debug设置为True和False,但是在压缩的情况下,这两种方法都不能工作。
发布于 2021-06-19 18:47:21
你在类名上有一个错误。这是CompressedManifestStaticFilesStorage,,不是Mainfest。如果IDE中不支持这种完成,我建议始终从docs复制粘贴。
https://stackoverflow.com/questions/68048882
复制相似问题