![](/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.