由<function wrapper =“” at =“” 0x7f39d480f230 =“”>启动的线程中未处理的异常

时间:2018-07-18 10:17:10

标签: python django

我在Django项目中遇到以下错误:

Traceback (most recent call last):
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/freddy/environments/py26_env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, 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/freddy/environments/balog/balog/urls.py", line 18, in <module>
    from django.urls import include, path
ImportError: cannot import name include

我正在使用:

>>> python -m django --version
1.11.14
>>> python --version
Python 2.7.15rc1

1 个答案:

答案 0 :(得分:0)

Django 1.11不使用path(在Django 2中添加)。您需要使用urlinclude位于同一位置。

from django.conf.urls import include, url

urlpatterns = [
    url(r'^admin/', admin.site.urls),
]