Django报错 Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
·
Django入门
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

跟着教程https://docs.djangoproject.com/zh-hans/2.0/intro/tutorial01 , 走到创建应用polls后,再运行
python manage.py runserver
打开localhost:8000 报错!小白,也不知道哪里错了,,,反复试,,还是不懂,最后认真得跟着教程走。
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
polls/
admin/
The empty path didn’t match any of these.
URLconf 是啥,
#polls/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
views是我们需要打开的视图,polls/urls.py是我们创建的URLconf,为了使得能在mysite项目下运行polls这个应用,我们还需在mysite/urls.py中引入polls.urls以便请求能够正确找到路径。
于是,在mysite/urls.py中配置URLconf,
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
path(‘admin/’, admin.site.urls)是该文件自带的,于是 试一下

既然这样
成功
好吧,原来加个在localhost:8000后加个/polls 请求到正确地址就行。。。。。
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)