Javascript 找不到DJango React

Javascript 找不到DJango React,javascript,python,css,reactjs,django,Javascript,Python,Css,Reactjs,Django,我是DJango的新手,我会做出反应。我在Pycharm中创建了一个DJango项目,然后使用npm create React app frontend创建了一个React应用程序。我在文件夹“src”中添加了一些JavaScript文件,并编辑了一个创建的automaticly index.css。我构建了React应用程序,然后启动了DJango服务器。控制台打印: Not Found: /src/index.css Not Found: /src/seigaiha.js [25/Dec/2

我是DJango的新手,我会做出反应。我在Pycharm中创建了一个DJango项目,然后使用npm create React app frontend创建了一个React应用程序。我在文件夹“src”中添加了一些JavaScript文件,并编辑了一个创建的automaticly index.css。我构建了React应用程序,然后启动了DJango服务器。控制台打印:

Not Found: /src/index.css
Not Found: /src/seigaiha.js
[25/Dec/2020 14:23:31] "GET /src/index.css HTTP/1.1" 404 2201
[25/Dec/2020 14:23:31] "GET /src/seigaiha.js HTTP/1.1" 404 2207
但是.css fle在发布的站点上是可访问的。js不是

文件夹中的顺序:

- frontend/
- - build/
- - - static/
- - - - css/ #here .css file after build has the same structure as index.css, so it buil
- - - - js/
- - - - media/
- - node-modules/
- - public/
- - src/
- - - index.css
- - - seigaiha.js
在settings.py中:

'DIRS': [
            os.path.join(BASE_DIR / 'frontend/build')
        ]
public/index.html
中:

***some code***
<link rel="stylesheet" type="text/css" href="./src/index.css">
***some code***
<div class="pattern">
    <canvas id="canvas">Canvas not supported.</canvas>
    <script src="src/seigaiha.js"></script>
</div>
***some code***
***一些代码***
***一些代码***
不支持画布。
***一些代码***
我做错了什么?也许我需要把这些文件放在另一个文件夹里?或者一条路错了。js文件名?当我只有.html、.css和js文件(不在react中)时,一切都正常


UPD:我在stackoverflow中阅读了一些建议,并使用了
npm start
命令代替
npm run build
。它不起作用。

试试这样的方法:

FRONTEND_DIR = os.path.abspath(os.path.join(BASE_DIR, "..", "front-end"))

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [os.path.join(FRONTEND_DIR, "build")],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]

STATICFILES_DIRS = (os.path.join(FRONTEND_DIR, "build", "static"),)