from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'), url(r'^(?P<pk>[0-9]+)/results/$', views.ResultsView.as_view(), name='results'), url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'), ]
then reload the polls app (http://localhost:8000/polls/), I got the following error:
'module' object has no attribute 'IndexView'
Traceback:
File "C:\Users\nti\Desktop\test_env\lib\site-packages\django\core\handlers\base.py" in get_response
119. resolver_match = resolver.resolve(request.path_info)
File "C:\Users\nti\Desktop\test_env\lib\site-packages\django\core\urlresolvers.py" in resolve
366. for pattern in self.url_patterns:
File "C:\Users\nti\Desktop\test_env\lib\site-packages\django\core\urlresolvers.py" in url_patterns
402. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\nti\Desktop\test_env\lib\site-packages\django\core\urlresolvers.py" in urlconf_module
396. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\Lib\importlib\__init__.py" in import_module
37. __import__(name)
File "C:\Users\nti\Desktop\test_env\myapp\myapp\urls.py" in <module>
21. url(r'^polls/', include('polls.urls', namespace="polls")),
File "C:\Users\nti\Desktop\test_env\lib\site-packages\django\conf\urls\__init__.py" in include
33. urlconf_module = import_module(urlconf_module)
File "C:\Python27\Lib\importlib\__init__.py" in import_module
37. __import__(name)
File "C:\Users\nti\Desktop\test_env\myapp\polls\urls.py" in <module>
25. url(r'^$', views.IndexView.as_view(), name='index'),
Exception Type: AttributeError at /polls/
Exception Value: 'module' object has no attribute 'IndexView'
--------------------------------
Do you have any clue to fix the problem?
Thanks.
Best regards,
Doaa
Did you complete the following section after changing the urls.conf? The URL changes won't work until you modify the views.py file in the next section.
https://docs.djangoproject.com/en/1.8/intro/tutorial04/#amend-views
-James
--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6f61448d-d30c-4d22-a198-75e33ceeefac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.