3

I am trying the tutorial and m stuck on views. It says "AttributeError: 'module' object has no attribute 'index'"

My project/urls.py says

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)),
)

In Views.py:

def index(request):
request HttpResponse("Hello, world. You're at the poll index.")

In app urls.py:

from django.conf.urls import patterns, url
from polls import views

ultrapatterns = patterns('', 
url(r'^$', views.index, name='index')
)

Kind advise is required with some short explanation so I can understand it.

9
  • 1
    Is that the entire content of your views.py file? Commented Dec 26, 2013 at 6:35
  • Problem still persists. Now it says "ImportError: cannot import name Views". After I've tried to change 'views to Views in app/urls.py page. Commented Dec 26, 2013 at 6:46
  • Can you provide a full traceback? Commented Dec 26, 2013 at 6:47
  • Please check the structure of your proyect: existence of __init__.py files for packages, correct use of package names (is it "polls" right), capitalization on names, and indentation (it doesn't look good in your question). Commented Dec 26, 2013 at 6:51
  • yes this is the entire content. Commented Dec 26, 2013 at 6:51

1 Answer 1

1

I got into this state when I didn't save my /polls/views.py file while following the tutorial 🙈

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.