【发布时间】:2020-04-06 04:40:20
【问题描述】:
我不断收到此错误:
- 找不到页面 (404)
- 请求方法:GET
- 请求网址:http://127.0.0.1:8000/home
使用
personal_portfolio.urls中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:
admin/
home/
当前路径 home 与其中任何一个都不匹配。
这是我整个项目的urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('home/', include('hello_world.urls')),
]
这是我的hello_world urls.py代码
from django.urls import path
from hello_world import views
urlpatterns = [
path('home/', views.hello_world, name='hello_world'),
]
这是我的 hello_world views.py 代码
from django.shortcuts import render
def hello_world(request):
return render(request, 'hello_world.html')
【问题讨论】: