我正在做django教程,所以我真的在剪切和粘贴代码。我在第1步中一直收到此错误
from django.conf.urls import url
from django.conf.urls import include
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
我收到此错误
*/django/theSite/polls/urls.py", line 8, in <module>
url(r'^$', views.index, name='index'),
AttributeError: 'module' object has no attribute 'index'
编辑: 我的观点模块是这个
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
我看不出我错过了你有什么建议吗?谢谢!
答案 0 :(得分:1)
答案确实是我的观点有问题。删除django项目并从头开始重建整个教程可以解决问题。