python - AttributeError : 'module' object has no attribute 'index' -


i'm going through official tutorial provided on django's documentation site, , have encountered attributeerror. here's code i'm working :

'polls' name of application.

views.py

from django.http import httpresponse  def index(request):     return httpresponse("hello, world. you're @ poll index.") 

\polls\urls.py

from django.conf.urls import patterns, url  polls import views  urlpatterns = patterns('',     url(r'^$', views.index, name='index') ) 

urls.py

from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('',     # examples:     # url(r'^$', 'mysite.views.home', name='home'),     url(r'^blog/', include('blog.urls')),     url(r'^polls/', include('polls.urls')),     url(r'^admin/', include(admin.site.urls)), ) 

error:

attributeerror @ /polls  'module' object has no attribute 'index'  request method:     request url:    http://localhost:8000/polls django version:     1.6.5 exception type:     attributeerror exception value:      'module' object has no attribute 'index'  exception location:     c:\users\manoj\desktop\django\mysite\polls\urls.py in <module>, line 6 python executable:  f:\python 2.7\python.exe python version:     2.7.5 python path:      ['c:\\users\\manoj\\desktop\\django\\mysite',  'f:\\python 2.7\\lib\\site-packages\\pip-1.4.1-py2.7.egg',  'c:\\windows\\system32\\python27.zip',  'f:\\python 2.7\\dlls',  'f:\\python 2.7\\lib',  'f:\\python 2.7\\lib\\plat-win',  'f:\\python 2.7\\lib\\lib-tk',  'f:\\python 2.7',  'f:\\python 2.7\\lib\\site-packages']  server time:    thu, 26 jun 2014 04:44:51 +0530 

what seems problem code ?


edit 1:

i replaced line

from polls import views 

with

from polls.views import index 

however, nameerror:

exception type:     nameerror exception value:      name 'views' not defined 

in 6th line of /polls/urls.py source code:

from django.conf.urls import patterns, url  polls.views import index  urlpatterns = patterns('',     url(r'^$', views.index, name='index') ) 

views.py should inside polls/views.py

from django.http import httpresponse  def index(request):     return httpresponse("hello, world. you're @ poll index.") 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -