我有一个简单的 django 设置,其中有一个名为“列表”的应用程序。我现在想http://127.0.0.1:8000/lists
展示这个应用程序。所以我将我的主要 urls.py 更改为以下内容:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^lists/', include('lists.urls')),
url(r'^admin/', include(admin.site.urls)),
)
我将位于列表文件夹(我的应用程序称为列表)中的 urls.py 更改为以下内容:
from django.conf.urls import patterns, url
from lists import views
urlpatterns = patterns(
url(r'^$', views.index, name='index')
)
据我所知,我完全按照 django 教程http://127.0.0.1:8000/lists
中的说明进行操作,但是当我访问(没有斜杠)时,它给了我以下错误:
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/lists
Using the URLconf defined in companyLists.urls, Django tried these URL patterns, in this order:
^lists/
^admin/
The current URL, lists, didn't match any of these.
当我访问http://127.0.0.1:8000/lists/
(带有斜杠)时,它给了我以下错误:
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/lists/
Using the URLconf defined in companyLists.urls, Django tried these URL patterns, in this order:
^admin/
The current URL, lists/, didn't match any of these.
我不明白为什么当我访问带有斜杠的网址时它不再搜索 ^lists/ 。有人知道我在这里做错了什么吗?
欢迎所有提示!