我正在做django
教程,但被困在这个https://docs.djangoproject.com/en/1.5/intro/tutorial03/上。
当我收到此错误时,我做了以下module has no attribute index
事情
polls/urls.py
# This is in polls/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the poll index.")
#This is in polls/url.py
from django.conf.urls import patterns, url
from polls import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'))
#This is in mysite/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',url(r'^polls/',include('polls.urls')),url(r'^admin/',include(admin.site.urls)),)
PS:在本教程之前,我一直遵循教程 1 和 2 并相应地完成了所有操作。