Quantcast

AttributeError: module 'polls.views' has no attribute 'index'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AttributeError: module 'polls.views' has no attribute 'index'

Billy Lin
I'm following the getting started tutorial 01 and running into issues after creating the polls app. Can someone please help?

I'm using Python 3.6.1 and Django 1.11.

Here's the detailed trace:

Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04222810>
Traceback (most recent call last):
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line
227, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
nserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", l
ine 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
16, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
26, in check_resolver
    return check_method()
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 25
4, in check
    for pattern in self.url_patterns:
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 40
5, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 39
8, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", lin
e 50, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\polls\urls.py", line 6, in <module>
    url(r'^$', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AttributeError: module 'polls.views' has no attribute 'index'

comeon

You didn't give us enough info, but I am thinking that you don't have an index() function in your polls/views.py. Start the tutorial from the beginning and follow it closely.

On Apr 19, 2017 4:17 PM, Billy Lin <[hidden email]> wrote:
I'm following the getting started tutorial 01 and running into issues after creating the polls app. Can someone please help?

I'm using Python 3.6.1 and Django 1.11.

Here's the detailed trace:

Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04222810>
Traceback (most recent call last):
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line
227, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
nserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", l
ine 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
16, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
26, in check_resolver
    return check_method()
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 25
4, in check
    for pattern in self.url_patterns:
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 40
5, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 39
8, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", lin
e 50, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\polls\urls.py", line 6, in <module>
    url(r'^$', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com?utm_medium&#61;email&amp;utm_source&#61;footer">https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/58f76969.57e41c0a.a9838.2b90SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AttributeError: module 'polls.views' has no attribute 'index'

Billy Lin
Thanks for your reploy.

Actually I followed the tutorial exactly.

My polls/views.py has:

from django.http import HttpResponse


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

My polls/urls.py has:

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]


On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:

You didn't give us enough info, but I am thinking that you don't have an index() function in your polls/views.py. Start the tutorial from the beginning and follow it closely.

On Apr 19, 2017 4:17 PM, Billy Lin <<a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="DfoUh6s5AwAJ">lce...@...> wrote:
I'm following the getting started tutorial 01 and running into issues after creating the polls app. Can someone please help?

I'm using Python 3.6.1 and Django 1.11.

Here's the detailed trace:

Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04222810>
Traceback (most recent call last):
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line
227, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
nserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", l
ine 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", l
ine 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
16, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line
26, in check_resolver
    return check_method()
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 25
4, in check
    for pattern in self.url_patterns:
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[<a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE3JOkg7Vn23FjpPTI8mfGhfDqO3A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE3JOkg7Vn23FjpPTI8mfGhfDqO3A&#39;;return true;" href="http://self.name" target="_blank" rel="nofollow">self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 40
5, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line
35, in __get__
    res = instance.__dict__[<a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE3JOkg7Vn23FjpPTI8mfGhfDqO3A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE3JOkg7Vn23FjpPTI8mfGhfDqO3A&#39;;return true;" href="http://self.name" target="_blank" rel="nofollow">self.name] = self.func(instance)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 39
8, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", lin
e 50, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_modu
le
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\polls\urls.py", line 6, in <module>
    url(r'^$', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="DfoUh6s5AwAJ">django-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="DfoUh6s5AwAJ">django...@....
Visit this group at <a onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow">https://groups.google.com/group/django-users.
To view this discussion on the web visit <a onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" href="https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow">https://groups.google.com/d/msgid/django-users/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com.
For more options, visit <a onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" href="https://groups.google.com/d/optout" target="_blank" rel="nofollow">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/062d20f9-0dcf-491d-bd8b-73f92ce7acc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...