尝试获取主网址格式时出现错误

问题描述 投票:0回答:2

我是Django的初学者,我创建了一个Django项目,当我在两个应用程序中都添加了urls.py文件时,我都包含了两个应用程序,两个应用程序都运行良好,但是当我获取主管理员URL时,错误

Page not found (404)
Request Method: GET
URL:    http://127.0.0.1:8000/
the URLconf defined in mac.urls, Django tried these URL patterns, in this order:

admin/
shop/
blog/
The empty path didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to 
 False, and Django will display a standard 404 page.

[当我在http://127.0.0.1:8000/中获取此URL时,我收到一条错误消息,指出该错误适用于http://127.0.0.1:8000/shop/

这是我的主要urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('shop.urls')),
path('blog/', include('blog.urls')),
]
python django url-pattern
2个回答
2
投票

您的django应用具有3条路线:http://127.0.0.1:8000/admin/转到Django admin应用http://127.0.0.1:8000/shop/转到您的shop应用http://127.0.0.1:8000/blog/转到您的blog应用


2
投票

创建一个将成为您的首页的视图。从那里您应该链接到网站的其他区域。不要将其引导给管理员,这太可笑了。

© www.soinside.com 2019 - 2024. All rights reserved.