如何解决当我尝试在我的 Django 项目中收集静态时,我得到了 Post-processing staticfiles\static\css\style.css failed
我正在尝试这个我没有得到任何解决方案..我说后处理'staticfiles\static\css\style.css'失败了!但是我的文件没有问题。我的这个项目在机器上运行没有任何错误你可以在这里查看我的 repo https://github.com/programmer-Quazi/personal-blog.git
这是我给出这个命令后的终端输出
python manage.py collectstatic
Post-processing 'staticfiles\static\css\style.css' Failed!
Traceback (most recent call last):
File "manage.py",line 22,in <module>
main()
File "manage.py",line 18,in main
execute_from_command_line(sys.argv)
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\core\management\__init__.py",line 419,in execute_from_command_line
utility.execute()
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\core\management\__init__.py",line 413,in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\core\management\base.py",line 354,in run_from_argv
self.execute(*args,**cmd_options)
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\core\management\base.py",line 398,in execute
output = self.handle(*args,**options)
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",line 187,in handle
collected = self.collect()
File "C:\Users\faald\AppData\Roaming\Python\python38\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",line 134,in collect
raise processed
whitenoise.storage.MissingFileError: The file 'staticfiles/static/img/elements/primary-check.png' Could not be found with <whitenoise.storage.CompressedManifestStaticFilesstorage object at 0x000001F9F6FF3280>.
The CSS file 'staticfiles\static\css\style.css' references a file which Could not be found:
staticfiles/static/img/elements/primary-check.png
Please check the URL references in this CSS file,particularly any
relative paths which might be pointing to the wrong location.
我的 settigns.py 文件是
"""
Django settings for djangoproject4 project.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file,see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values,see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import django_heroku
import dj_database_url
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# Security WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-bdytm3$mnq+xpi3pa*l=^n9^56gsq7&kga0)h=p#77#9t$t!rl'
# Security WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application deFinition
INSTALLED_APPS = [
'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','blog','storages','taggit',# 'django_quill'
]
INSTALLED_APPS += ('django_summernote',)
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 = 'djangoproject4.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [ 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 = 'djangoproject4.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3','NAME': BASE_DIR / 'db.sqlite3',}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS,JavaScript,Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_Dirs = [BASE_DIR,'static']
STATIC_ROOT = BASE_DIR,'static_root'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesstorage'
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media/'
AWS_ACCESS_KEY_ID = 'AKIARVGPJVYVssLNFAAMTG'
AWS_SECRET_ACCESS_KEY = 'KiHvGcSD4xWB1si/WocUwoflFQJAt3x0UJss9kuDDz'
AWS_STORAGE_BUCKET_NAME = 'naassim.secpspstorage'
AWS_S3_FILE_OVERWRITE = False
# AWS_QUERYSTRING_AUTH = False
AWS_DEFAULT_ACL = None
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
X_FRAME_OPTIONS= 'SAMEORIGIN'
django_heroku.settings(locals())
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。