0
我在做django
教程,但被卡在這一個https://docs.djangoproject.com/en/1.5/intro/tutorial03/。
我做了以下的事情,當我在 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)),)
得到這個錯誤module has no attribute index
PS:截至本教程中,我都跟着教程1和2也相應做了一切。
嘗試重新啓動apache或你的IDE ... – grigno
如果你使用開發服務器'manage.py runserver',在'polls import views'下面添加'print views .__ dict__'',什麼是輸出? –
你確定你打開過'http:// localhost:8000/polls /'嗎? – Silwest