Django Web Tutorial的问题

时间:2015-01-09 22:02:23

标签: python django

我对编程非常陌生。我在这里搜索并发现了一些类似的线程,但不幸的是,这些线程中的答案似乎并没有解决我自己的问题。

问题

我正在通过Django教程,我正在进行第三个教程: https://docs.djangoproject.com/en/1.7/intro/tutorial03/

我不确定这是否重要,但我正在使用Macintosh小牛队。

我工作的根目录是'Test2'。目录结构是:

/用户/ ME / SRC / collact / collact / TEST2 /

在'test2'中,根据前两个教程,我有'/ polls'和'/ templates'文件夹。

我的民意调查/ views.py文件包含以下文字:

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

我的民意调查/ urls.py文件包含以下文字:

from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
)

最后,在/ test2 /中,我还有一个urls python文件(.py)。它有文字:

from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns('',
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

据我所知,这是本教程规定的内容。不幸的是,当我使用: python manage.py runserver 运行服务器时,该网站给了我一条错误/ 404消息:

Page not found (404)
Request Method:
GET Request
URL: http://localhost:8000/polls/ Using the URLconf defined in
test2.urls, Django tried these URL patterns, in this order: ^admin/
The current URL, polls/, 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.

有谁知道如何解决这个问题?我知道这是一个非常愚蠢的问题,但我一直试图弄清楚过去一两天,不幸的是我只是不熟悉编程来自行解决这个问题。

0 个答案:

没有答案