Attribute error in urls.py
我正在做Django教程,所以我实际上是在剪切和粘贴代码。我一直在第一步遇到这个错误
1 2 3 4 5 6 7 8 | from django.conf.urls import url from django.conf.urls import include from . import views urlpatterns = [ url(r'^$', views.index, name='index'), ] |
我有这个错误
1 2 3 | */django/theSite/polls/urls.py", line 8, in <module> url(r'^$', views.index, name='index'), AttributeError: 'module' object has no attribute 'index' |
编辑:我的视图模块是
1 2 3 4 5 6 7 8 | 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.") |
我看不见我错过了什么。你有什么建议吗?谢谢!
答案确实是我的观点一定有问题。删除django项目并从头开始重建整个教程,解决了这个问题。