Django可能是我弄乱了seting.py文件,还是我的代码有问题?

2024-09-29 00:16:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码一直在工作,直到我为页眉和页脚创建了base.html模板。我取消了对项目的大部分更改并重新运行服务器,但仍在网页上显示此错误:

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

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('Website.urls')),
]




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

admin/
Home.html [name='Home']
contact.html [name='contact']
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.

终端给出此错误:

System check identified no issues (0 silenced).
June 16, 2020 - 09:22:12
Django version 3.0.7, using settings 'DIALYSIS.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Watching for file changes with StatReloader
Not Found: /
[16/Jun/2020 09:26:57] "GET / HTTP/1.1" 404 2267
C:\DialysisCenter\DIALYSIS\DIALYSIS\settings.py changed, reloading.
Performing system checks...

System check identified no issues (0 silenced).
June 16, 2020 - 09:25:29
Django version 3.0.7, using settings 'DIALYSIS.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Watching for file changes with StatReloader
Not Found: /
[16/Jun/2020 09:29:40] "GET / HTTP/1.1" 404 2267
Not Found: /
[16/Jun/2020 09:29:41] "GET / HTTP/1.1" 404 2267
Not Found: /
[16/Jun/2020 09:29:46] "GET / HTTP/1.1" 404 2267
Performing system checks...

System check identified no issues (0 silenced).
June 16, 2020 - 09:29:39
Django version 3.0.7, using settings 'DIALYSIS.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
(virtual)

这是我的URL.py代码


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

    urlpatterns = [
        path('admin/', admin.site.urls),
        path('',include('Website.urls')),
    ]


Tags: thepathdjangofromimporthttpgetsettings