当我运行react脚本'yarn start'时,我到index.html中manifest.json的链接有效,但当我运行'python3 manage.py runserver'时则无效 [英] My link to manifest.json in index.html works when I run react script 'yarn start', but not when I run 'python3 manage.py runserver'

查看:102
本文介绍了当我运行react脚本'yarn start'时,我到index.html中manifest.json的链接有效,但当我运行'python3 manage.py runserver'时则无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行'yarn start'时,我在index.html文件中指向manifest.json的链接工作正常,但是当我运行'python3 manage.py runserver'时,一切都在终端中是:

When I run 'yarn start', my link to manifest.json in my index.html file works fine, but when I run 'python3 manage.py runserver' all I get in the terminal is:

Not Found: /manifest.json
"GET /manifest.json HTTP/1.1" 404 2234

这也发生在我所有的静态链接和导入中.我对Django和React以及整个编程领域还很陌生,所以我认为我只是缺少一些简单的东西,但我无法弄清楚.

This also happens to all of my static links and imports. I'm pretty new to Django and React, and programming as a whole, so I think that I'm just missing something simple, but I can't figure it out.

我一直在尝试使用 {%load static%} ,但是即使我在设置中编辑 STATIC_URL ,该链接也无效.py 指向我的 manifest.json 目录.我也尝试编辑 view.py urls.py ,但是我得到的只是终端中的语法错误.除此之外,我一无所知.

I've been trying to use {% load static %}, but the link doesn't work, even if I edit STATIC_URL in settings.py to point towards my manifest.json directory. I also attempted to edit view.py and urls.py, but all I get is syntax errors in the terminal. Other than that I'm clueless.

frontend/public/index.html

frontend/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>

frontend/urls.py

frontend/urls.py


from django.urls import path
from . import views
from django.conf.urls.static import static


urlpatterns = [
    path('', views.index),

]

frontend/views.py

frontend/views.py

from django.shortcuts import render

def index(request):
    return render(request, 'frontend/public/index.html')

我希望我的浏览器可以正确加载manifest.json以及任何其他链接或导入,但是我一直得到空白页.

I expected my browser to load manifest.json properly, along with any other links or imports, but I keep getting a blank page.

我在Django内部使用React,因此当我尝试导入 index.js 时,会弹出相同的未找到"终端错误.我假设如果我解决了 manifest.json 问题,我还将解决其他导入和链接问题.

Im using React inside of Django, so when I tried to import my index.js the same "Not Found" terminal error popped up. Im assuming that if I solve the manifest.json problem, I'll also solve my other import and link problems.

推荐答案

我遇到了同样的问题,并发现了这个

I had the same issue and found this Can't get rid of missing manifest.json error
Well, in my case it was browser cache related and swapping to incognito mode was enough.

这篇关于当我运行react脚本'yarn start'时,我到index.html中manifest.json的链接有效,但当我运行'python3 manage.py runserver'时则无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆