我对使用 Django 很陌生,我一直依赖一些教程将这个链接到 React,但问题是最初(当我打开 127.0.0.1:8000 时)React 完美地加载了路由,然后当我重新加载页面 Django 试图从中解释路径urls.py,但显然找不到它。
错误是:
Page not found (404) Using the URLconf defined in memberstack.urls, Django tried these URL patterns, in this order:
admin/
api/token-auth/
core/
我希望你能帮助我,在此先感谢
我的项目/urls.py
from django.contrib import admin
from django.urls import path, include
from rest_framework_jwt.views import obtain_jwt_token
from frontend.views import index
urlpatterns = [
path('', include('frontend.urls')),
path('admin/', admin.site.urls),
path('api/token-auth/', obtain_jwt_token),
path('core/', include('core.urls')),
]
前端/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
]
前端/views.py
from django.shortcuts import render
def index(request):
return render(request, 'frontend/index.html')
慕后森
相关分类