![](/img/trans.png)
[英]Using the URLconf defined in lecture3.urls, Django tried these URL patterns, in this order: admin/ The current path, hello/, didn’t match any of thes
[英]Using the URLconf defined in lec3.urls, Django tried these URL patterns, in this order: admin/ hello/ The empty path didn't match any of these
這些是我為創建 wepapp 而編寫的主要代碼,但我收到了這個 404 錯誤,所以請幫助我的 hello urls.py
from django.urls import path
from hello import views
urlpatterns = [
path("", views.index, name="index")
]
我的 urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', include("hello.urls")),
]
我的觀點.py
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def index(request):
return HttpResponse("hello, orld")
看起來您正在index
使用
http://127.0.0.1:8000/
。 這不起作用,因為您的index
包含在hello
的 urls.py 中,並且hello
的 url 以hello/
開頭。
嘗試
http://127.0.0.1:8000/hello
反而。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.