【发布时间】:2019-02-18 12:49:01
【问题描述】:
我今天才开始使用 django。
我尝试执行运行服务器命令,但一直遇到Page not found error。
我已经尝试调试这个问题将近一个小时了。
项目 rms > myrms(应用程序)
编辑:
我最初对 url 模式声明进行了双重定义,这是 meshy 指出的。我更正了该错误,但代码仍然无法正常工作。帮助。
myrms/view.py
>from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello,World. You're at the polls index.")
myrms/urls.py
>from django.contrib import admin
from django.urls import include, path
from . import views
urlpatterns = [
path('', views.index,name = 'index'),
path('myrms/', include('myrms.urls')),
path('admin/', admin.site.urls),
]
预计会显示 hello world 声明,但不断出现Page not found error
在运行 manage.py runserver
正在执行系统检查...
System check identified no issues (0 silenced).
February 18, 2019 - 18:41:24
Django version 2.1.7, using settings 'RMS.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[18/Feb/2019 18:41:36] "GET /myrms/ HTTP/1.1" 404 77
我正在尝试打开。 url"http://localhost:8000/myrms/" 或 "http://127.0.0.1:8000/myrms/" 都显示错误
【问题讨论】:
-
提供索引更改 url 模式
''到'^$' -
嗨。你能详细说明这有什么帮助吗>
-
请添加一些信息:a) 在
python manage.py runserver之后你会得到什么,b) 你试图打开哪个 url,c) 错误堆栈跟踪 - 从“找不到页面”复制粘贴文本错误”,d) 看看你的命令行 - 什么manage.py runserver打印? -
你修改了你的问题,我的回答现在已经过时了。
-
@meshy 您帮助消除了另一个错误。无论如何它必须对OP有帮助