Friday, February 26, 2016

Re: errors while trying to add extra context (detailview, __getitem__)

JAMES wrote:  >>> Can you post the entire section for your urls.py, as well as the entire traceback? Nothing is immediately jumping out at me. Do you get this error when you start the Django server, or when you visit the page that matches this URL?

This error comes when I try to start the server.

I am starting the traceback here because at first I had it as a free standing module and not inside views.py, but i thought they said a view is a callable and so can be anywhere and be named anything?

 File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'

Why? It is clearly subclassed from list view. I got it straight from the docs

https://docs.djangoproject.com/en/1.9/topics/class-based-views/mixins/

Then I put it in views.py. Now I see an unhandled exception, but I don't know what it means or what to do about it.

 File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 9, in <module>
    from essell.views import CodeDetail
ImportError: cannot import name CodeDetail
Unhandled exception in thread started by <function wrapper at 0x7f85a2b7e230>
Traceback (most recent call last):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
    dt_settings.patch_all()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 228, in patch_all
    patch_root_urlconf()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 216, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 568, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in app_dict
    self._populate()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 293, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/jamf/urls.py", line 14, in <module>
    url(r'^library/', include('essell.urls')),
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'
Unhandled exception in thread started by <function wrapper at 0x7f8f9b061410>
Traceback (most recent call last):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
    dt_settings.patch_all()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 228, in patch_all
    patch_root_urlconf()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 216, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 568, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in app_dict
    self._populate()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 293, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/jamf/urls.py", line 14, in <module>
    url(r'^library/', include('essell.urls')),
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'
Unhandled exception in thread started by <function wrapper at 0x7f4249981410>
Traceback (most recent call last):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
    dt_settings.patch_all()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 228, in patch_all
    patch_root_urlconf()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 216, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 568, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in app_dict
    self._populate()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 293, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/jamf/urls.py", line 14, in <module>
    url(r'^library/', include('essell.urls')),
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'
Unhandled exception in thread started by <function wrapper at 0x7fddcc7ed410>
Traceback (most recent call last):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
    dt_settings.patch_all()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 228, in patch_all
    patch_root_urlconf()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 216, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 568, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in app_dict
    self._populate()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 293, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/jamf/urls.py", line 14, in <module>
    url(r'^library/', include('essell.urls')),
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'
/home/malikarumi/Projects/cannon/jamf/essell/urls.py:24: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
  url(r'^constitution', CodeListViewAll.as_view(), name='constitution'), #(2)

Unhandled exception in thread started by <function wrapper at 0x7f4d279d18c0>
Traceback (most recent call last):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
    dt_settings.patch_all()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 228, in patch_all
    patch_root_urlconf()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 216, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 568, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in app_dict
    self._populate()
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 293, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/malikarumi/Projects/cannon/jamf/jamf/urls.py", line 15, in <module>
    url(r'^admin/', include(admin.site.urls)),
TypeError: 'function' object has no attribute '__getitem__'

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/845e47fd-a8f2-4517-a565-958887a5d34a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment