在Django应用程序中加载静态文件

问题描述 投票:0回答:1

我有一个django应用程序,并尝试通过django项目加载前端。我的index.html是:

<link rel="icon" type="image/x-icon" href="favicon.ico">
  {% load static %}
<link rel="stylesheet" href="{% static "styles.38614f36c93ac671679e.css" %}"></head>
<body>
<app-root></app-root>
{% load static %}
<script type="text/javascript" src="{% static "runtime.a66f828dca56eeb90e02.js" %}"></script><script type="text/javascript" src="{% static "polyfills.f3fc5ca24d1323624670.js" %}"></script><script type="text/javascript" src="{% static "scripts.5bde77e84291ce59c080.js" %}"></script><script type="text/javascript" src="{% static "main.e7b9143f2f482d6d3cc7.js" %}"></script></body>
</html>

并且在项目文件的settings.py中,我已经添加了静态文件设置:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

我的项目结构是:

apt.yml     DCMS_API/  infra/  manage.py*    odbc-cfg/  requirements.txt  static/       templates/
Authorize/  facility/  manifest.yml  Procfile   runtime.txt

当我将代码上传到Cloud Foundry并尝试运行其显示的应用程序时,>]

ERR Not Found: /static/runtime.a66f828dca56eeb90e02.js
ERR Not Found: /static/styles.38614f36c93ac671679e.css
ERR Not Found: /static/polyfills.f3fc5ca24d1323624670.js
ERR Not Found: /static/scripts.5bde77e84291ce59c080.js
ERR Not Found: /static/main.e7b9143f2f482d6d3cc7.js

我想念什么?

我有一个django应用程序,并尝试通过django项目加载前端。我的index.html是: {%load static%}

django gunicorn cloudfoundry
1个回答
0
投票

您是否运行过python manage.py collectstatic吗?

© www.soinside.com 2019 - 2024. All rights reserved.