Django:无法导入名称默认值

时间:2014-02-01 02:35:49

标签: django

在我开始使用virtualenv之前它运作良好,我做到了这一点,然后突然提示追溯:

File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 90, in get_response
    response = middleware_method(request)
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/middleware/common.py", line 71, in process_request
    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 573, in is_valid_path
    resolve(path, urlconf)
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 453, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 318, in resolve
    for pattern in self.url_patterns:
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 346, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/home/admort/Projects/django_code/findyourmatch/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/admort/Projects/django_code/findyourmatch/findyourmatch/urls.py", line 4, in <module>
    from django.conf.urls.defaults import *
ImportError: No module named defaults

我在url.py

中有这个
from django.conf.urls.defaults import *

我无法理解这个问题,经过一些尝试解决后我才在这里。

1 个答案:

答案 0 :(得分:2)

看来你正在使用Django 1.6

使用:

from django.conf.urls import *  

也不要导入所有内容。仅导入您需要的东西。

e.g。 from django.conf.urls import patterns