我正在尝试教程而且我坚持观点。 它说“AttributeError:'module'对象没有属性'index'”
我的项目/ 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)),
)
在Views.py中:
def index(request):
request HttpResponse("Hello, world. You're at the poll index.")
在app urls.py中:
from django.conf.urls import patterns, url
from polls import views
ultrapatterns = patterns('',
url(r'^$', views.index, name='index')
)
需要一些简短的解释,以便我理解它。
答案 0 :(得分:1)
当我在遵循教程时没有保存/polls/views.py文件时,我进入了这种状态