【问题标题】:Chrome says 'No manifest detected' when manifest.json is served by Django当 Django 提供 manifest.json 时,Chrome 显示“未检测到清单”
【发布时间】:2019-03-07 19:35:40
【问题描述】:

我在后端有一个带有 Django 的 SPA。我试图让它成为一个渐进式的网络应用程序。我制作了 manifest.json 并将其链接到我的 index.html 中:

<link rel="manifest" href="/static/manifest.json">

Chrome 无法检测到它。我的index.html 是一个Django 模板,存储在templates 目录中,只能通过Django 路由/ 访问。 Manifest.json 位于 static 目录中,并作为常规静态文件提供给前端。我认为这是无法检测到清单的原因 - index.html 无法访问。我对吗?如果是这样,你能给我一个关于如何使它工作的建议吗?

【问题讨论】:

  • 直接去 /static/manifest.json 会发生什么?你能看到数据吗?
  • 是的,我可以通过这种方式访问​​ manifest.json。虽然,如果这很重要,则不是 index.html。
  • 不知道为什么您认为您应该能够访问 index.html。它是一个模板,而不是一个页面。并且模板位于单独目录中的事实根本没有相关性。
  • 我希望我没有让自己变得晦涩难懂。我认为 index.html 无法与 manifest 相提并论的事实是无法加载 manifest 文件的原因。
  • 您在控制台中看到了什么错误?

标签: django progressive-web-apps


【解决方案1】:

试试

load static
{% static "manifest.json" %}

这里的语法是{% static "path/relative/to/static/folder" %}

【讨论】:

  • 写 {% static "manifest.json" %} 结果是 "/static/manifest.json" 所以没有区别。
猜你喜欢
  • 2021-11-22
  • 1970-01-01
  • 2021-10-27
  • 2018-04-13
  • 1970-01-01
  • 2014-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多