django version 1.10.3 django restframework error: 'module' object has no attribute 'snippet_list'

146 views
Skip to first unread message

马鑫

unread,
Nov 30, 2016, 11:02:03 PM11/30/16
to Django developers (Contributions to Django itself)

 Tutorial : http://www.django-rest-framework.org/tutorial/1-serialization/#

Error message:
(env)[root@iZ281jn3x0bZ tutorial]# python manage.py runserver 115.xx.xxx.32:8000
Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x2641a28>
Traceback (most recent call last):
  File "/root/django/rest/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/management/base.py", line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/management/base.py", line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/root/django/rest/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/rest/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/django/rest/tutorial/tutorial/urls.py", line 20, in <module>
    url(r'^', include('snippets.urls')),
  File "/root/django/rest/env/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/django/rest/tutorial/snippets/urls.py", line 5, in <module>
    url(r'^snippets/$', views.snippet_list),
AttributeError: 'module' object has no attribute 'snippet_list'

MMeent

unread,
Nov 30, 2016, 11:21:55 PM11/30/16
to Django developers (Contributions to Django itself)
Hi,

I'd like to mention that this is not the correct mailing list for issues like this, but this error is due to your 'views.py' not having the 'snippet_list' function [1], and therefore not being able to be imported.

I hope this helps, but this is a mailing list for django (internal) development usage. Please google first, or contact the package maintainer, or try the django-users list instead.

-Matthias

[1] see the second code block of http://www.django-rest-framework.org/tutorial/1-serialization/#writing-regular-django-views-using-our-serializer
Reply all
Reply to author
Forward
0 new messages