Django和React中的TemplateDoesNotExist

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

当我运行python manage.py runserver时>

在后端,它显示模板不存在

在前端,它显示500错误消息

在我的settings.py

中,我指定了:
import os

BASE_DIR = os.path.dirname(os.path.dirname(
    os.path.dirname(os.path.abspath(__file__))))
SECRET_KEY = '-05sgp9!deq=q1nltm@^^2cc+v29i(tyybv3v2t77qi66czazj'
DEBUG = True
ALLOWED_HOSTS = []
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_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',
            ],
        },
    },
]

ProductList.js

中>
componentDidMount() {
    this.setState({ loading: true });
    axios
      .get(productListURL)
      .then(res => {
        console.log(res.data);
        this.setState({ data: res.data, loading: false });
      })
      .catch(err => {
        this.setState({ error: err, loading: false });
      });
  }

当我在后台运行python manage.py runserver时,它在后端显示不存在模板,在前端,它显示500错误消息在我的settings.py中,我指定了:import os BASE_DIR = os.path ....

python django reactjs
1个回答
0
投票

可以通过运行解决此错误

终端中的[npm run build

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.