Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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
Django ValueError:缺少staticfiles清单条目,但清单似乎显示了该条目_Django_Heroku_Django Staticfiles_Whitenoise - Fatal编程技术网

Django ValueError:缺少staticfiles清单条目,但清单似乎显示了该条目

Django ValueError:缺少staticfiles清单条目,但清单似乎显示了该条目,django,heroku,django-staticfiles,whitenoise,Django,Heroku,Django Staticfiles,Whitenoise,在部署到Heroku的Django 1.11应用程序上。加载根URL/时(我假设Django在主页.html模板中到达{%static'angular/angular.min.js%}时),我得到以下错误: ValueError:缺少“angular/angular.min.js”的staticfiles清单条目 文件“django/core/handlers/exception.py”,第41行,在内部 响应=获取响应(请求) 文件“django/core/handlers/base.py”,

在部署到Heroku的Django 1.11应用程序上。加载根URL
/
时(我假设Django在
主页.html
模板中到达
{%static'angular/angular.min.js%}
时),我得到以下错误:

ValueError:缺少“angular/angular.min.js”的staticfiles清单条目
文件“django/core/handlers/exception.py”,第41行,在内部
响应=获取响应(请求)
文件“django/core/handlers/base.py”,第187行,在\u get\u响应中
response=self.process\u异常\u由\u中间件(e,请求)
文件“django/core/handlers/base.py”,第185行,在\u get\u响应中
响应=包装的回调(请求,*回调参数,**回调参数)
主页第87行的文件“homepage/views.py”
“最新的\u python3”:Version.objects.filter(支持\u python3=True)。选择\u相关的(“包”).distinct()。排序依据(“-created”)[0:5]
文件“django/shortcuts.py”,第30行,在渲染中
content=loader.render_to_string(模板名称、上下文、请求、using=using)
文件“django/template/loader.py”,第68行,位于render_to_字符串中
返回template.render(上下文、请求)
文件“django/template/backends/django.py”,第66行,在render中
返回self.template.render(上下文)
文件“django/template/base.py”,第207行,在render中
返回self.\u呈现(上下文)
文件“newrelic/api/function_trace.py”,第60行,在动态_包装器中
已包装退货(*args,**kwargs)
文件“django/template/base.py”,第199行,在渲染中
返回self.nodelist.render(上下文)
文件“django/template/base.py”,第990行,在render中
位=节点。带注释的渲染(上下文)
文件“django/template/base.py”,第957行,在render_注释中
返回self.render(上下文)
文件“django/template/loader_tags.py”,第177行,在渲染中
返回编译的\u父对象。\u呈现(上下文)
文件“newrelic/api/function_trace.py”,第60行,在动态_包装器中
已包装退货(*args,**kwargs)
文件“django/template/base.py”,第199行,在渲染中
返回self.nodelist.render(上下文)
文件“django/template/base.py”,第990行,在render中
位=节点。带注释的渲染(上下文)
文件“django/template/base.py”,第957行,在render_注释中
返回self.render(上下文)
文件“django/template/defaulttags.py”,第411行,在render中
返回\u标记(self.nodelist.render(context.strip())之间的strip\u空格\u
文件“django/template/base.py”,第990行,在render中
位=节点。带注释的渲染(上下文)
文件“django/template/base.py”,第957行,在render_注释中
返回self.render(上下文)
文件“newrelic/hooks/framework_django.py”,第765行,在包装器中
已包装退货(*args,**kwargs)
文件“django/template/loader_tags.py”,第72行,在render中
结果=block.nodelist.render(上下文)
文件“django/template/base.py”,第990行,在render中
位=节点。带注释的渲染(上下文)
文件“django/template/base.py”,第957行,在render_注释中
返回self.render(上下文)
文件“django/templatetags/static.py”,第105行,在render中
url=self.url(上下文)
url中第102行的文件“django/templatetags/static.py”
返回self.handle\u simple(路径)
文件“django/templatetags/static.py”,第117行,handle_simple
返回staticfiles\u storage.url(路径)
url中第162行的文件“django/contrib/staticfiles/storage.py”
返回self.\u url(self.storaged\u名称、名称、强制)
文件“django/contrib/staticfiles/storage.py”,第141行,在url中
散列名称=散列名称函数(*args)
文件“django/contrib/staticfiles/storage.py”,第432行,存储名称
raise VALUERROR(“缺少'%s'%clean\u name的staticfiles清单项”)
舱单上有什么? 我的理解是清单是一个名为
staticfiles.json
的文件。该文件似乎包含正确的条目(由于格式原因,我已删除所有不相关的条目):

相关设置: 我接着说:

requirements.txt中的
#
白噪声
#在设置/base.py中
BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(u文件_u)))
STATIC\u ROOT=os.path.join(BASE\u DIR,“staticfiles”)
STATIC_URL=“/STATIC/”
STATICFILES_DIRS=[os.path.join(BASE_DIR,“static”),]
中间件=[
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
#……这里也有其他人
]
django_heroku.settings(locals())
(更新:静态文件存储)
根据以下建议之一,我删除了STATICFILES\u存储的值。django heroku将
STATICFILES\u STORAGE
的值设置为
whitenoise.STORAGE.CompressedManifestStaticFilesStorage
。我通过将
del STATICFILES\u STORAGE
添加到我的settings.py文件的末尾,删除了这个选项。Django然后将该值重置为默认值
Django.contrib.staticfiles.storage.StaticFilesStorage
。结果是,所有静态文件都会在浏览器中出现404或MIME类型错误

您是否手动创建了
staticfiles
目录,然后在部署之前运行了
django admin collectstatic


以下是有关此问题的详细信息。

更新:此问题现已修复。遗憾的是,这个解决方案对其他人没有用处。对此表示歉意。问题是我的设置被导入的另一个模块中的设置覆盖。我在上面问题中列出的设置实际上对Heroku有效。很抱歉,各位,感谢那些帮助我调试的人。

对通过搜索登陆这里的人的提示 我也有同样的问题,在我的例子中,我必须删除开头的斜杠

{%static'/admin/js/vendor/jquery/jquery.js%}
更改为
{%static'admin/js/vendor/jquery/jquery.js%}
修复了我案例中的问题


我知道这与这个问题没有直接关系,但因为我带着我的问题来到这里,我想我会把它贴在这里,希望这会发生
$ heroku run cat ./staticfiles/staticfiles.json
Running cat ./staticfiles/staticfiles.json
{"paths": {"angular/angular.min.js": "angular/angular.min.df1c56732ca5.js", "angular/controllers.js": "angular/controllers.af8e9f9a2645.js"}, "version": "1.0"}