没有名为defaults python django的模块

时间:2014-11-12 12:28:45

标签: python django

安装石墨后,访问URL

时不会抛出名为defaults的模块

enter image description here

我的Urls.py持有以下导入

from django.conf.urls import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

这是我的完整堆栈跟踪

Environment:


Request Method: GET
Request URL: http://10.105.202.72/

Django Version: 1.6.8
Python Version: 2.6.6
Installed Applications:
('graphite.metrics',
 'graphite.render',
 'graphite.cli',
 'graphite.browser',
 'graphite.composer',
 'graphite.account',
 'graphite.dashboard',
 'graphite.whitelist',
 'graphite.events',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'tagging')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  99.                 resolver_match = resolver.resolve(request.path_info)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
  337.             for pattern in self.url_patterns:
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in url_patterns
  365.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in urlconf_module
  360.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
  40.         __import__(name)
File "/opt/graphite/webapp/graphite/urls.py" in <module>
  23.   ('^render/?', include('graphite.render.urls')),
File "/usr/lib/python2.6/site-packages/django/conf/urls/__init__.py" in include
  26.         urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
  40.         __import__(name)
File "/opt/graphite/webapp/graphite/render/urls.py" in <module>
  15. from django.conf.urls.defaults import *

Exception Type: ImportError at /
Exception Value: No module named defaults

1 个答案:

答案 0 :(得分:5)

您在urls.py中使用的导入:

from django.conf.urls.defaults import *
Django 1.6中

已弃用

您需要更改旧版本:

from django.conf.urls import *

查看已弃用功能的官方文档:here