当我运行“yarn start”时,我的index.html 文件中的manifest.json 链接工作正常,但是当我运行时'python3 manage.py runserver'
我在终端得到的只是:
Not Found: /manifest.json
"GET /manifest.json HTTP/1.1" 404 2234
我的所有静态链接和导入也会发生这种情况。我对 Django 和 React 以及整个编程都很陌生,所以我认为我只是错过了一些简单的东西,但我无法弄清楚。
我一直在尝试使用{% load static %}
,但即使我编辑,链接也不起作用STATIC_URL
in settings.py
指向我的manifest.json
目录。我也尝试编辑view.py
and urls.py
,但我得到的只是终端中的语法错误。除此之外我一无所知。
前端/public/index.html
<html>
<head>
<title>WebProject</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel="manifest" href="manifest.json"/>
</head>
<body style="background-color: #FAF0E6; font-family: Verdana; font-size: 40px;">
<div id="root"></div>
</body>
</html>
前端/urls.py
from django.urls import path
from . import views
from django.conf.urls.static import static
urlpatterns = [
path('', views.index),
]
前端/views.py
from django.shortcuts import render
def index(request):
return render(request, 'frontend/public/index.html')
我希望我的浏览器能够正确加载 manifest.json 以及任何其他链接或导入,但我不断收到空白页面。
我在 Django 中使用 React,所以当我尝试导入我的index.js
弹出相同的“未找到”终端错误。我假设如果我解决了manifest.json
问题,我还将解决其他导入和链接问题。