首页 > 解决方案 > 在 Django 服务器上找不到页面 404?

问题描述

我正在上 Django 课程,只有在我的第一个教程中,我在将 URL 映射到视图时收到“发现 404 错误页面”。我参考了此链接并执行了相同的步骤,但仍然遇到相同的错误。

https://docs.djangoproject.com/en/3.0/intro/tutorial01/

polls/urls.py
-------------
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
polls/view.py
-------------
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")
mysite/urls.py
--------------
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
  path('polls/', include('polls.urls')),
  path('admin/', admin.site.urls),
 ]

我的代码目录

帮我解决错误...我检查了所有来源并完全按照链接...仍然无法正常运行

标签: pythondjangodjango-viewsdjango-urlsurl-mapping

解决方案


推荐阅读