我按照教程中的说明操作
我为调试做了一个更改,这里是文件:
mysite1\urls.py:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^abc/', include('polls.urls')),
url(r'^polls/', admin.site.urls),
url(r'^admin/', admin.site.urls),
]
Run Code Online (Sandbox Code Playgroud)
文件:mysite1\polls\urls.py
from django.conf.urls import url
from .import views
urlpatterns = [
url(r'^&', views.index, name='index'),
]
Run Code Online (Sandbox Code Playgroud)
现在,如果我访问该站点,http://127.0.0.1:8000/polls/则会显示与访问该站点相同的登录页面http://127.0.0.1:8000/admin/.
但是,如果我去网站,http://127.0.0.1:8000/abc/它会给我以下内容:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/abc
Using the URLconf defined in mysite1.urls, Django tried these URL patterns, in this order:
^abc/
^polls/
^admin/
The current URL, abc, 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.
Run Code Online (Sandbox Code Playgroud)
有人可以指导我做错了吗?
在mysite1\polls\urls.py它应该是
url(r'^$', views.index, name='index'),
Run Code Online (Sandbox Code Playgroud)
请注意,您的代码有一个&而不是$.$表示字符串结束匹配字符.
| 归档时间: |
|
| 查看次数: |
904 次 |
| 最近记录: |