我无法为 Django Apps 教程渲染页面

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

我正在使用 django 教程创建我的第一个民意调查应用程序并学习 Django

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

这是我迄今为止创建的文件:

my app's file structure

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),
]

polls/urls.py
我有这个:


from django.urls import path

from . import views

urlpatterns = [
    path("", views.index, name="index"),
]

polls/views.py
我有以下内容:


from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

我一直在尝试使用 http://localhost:8000/polls/ 但它仍然不起作用!有什么想法请解释为什么会这样吗?

booo!

我已尽我所能进行调试,但对我来说一切看起来都是正确的。我正在使用 GitHub 的 IDE,但我认为这不应该是问题所在。

python django http server django-views
1个回答
0
投票

看起来您没有运行服务器,请运行以下命令:

 python manage.py runserver
© www.soinside.com 2019 - 2024. All rights reserved.