突然之间,我似乎无法访问我的django应用上的管理员。这是我收到的错误信息,不知道会发生什么?自从我上次打开它以来,我不认为我更改了任何管理员或设置数据。
/ admin / login /中的ImportError 没有名为后端的模块 请求方法:POST 请求网址:http://localhost:8000/admin/login/?next=/admin/ Django版本:1.9.dev20150119161257 异常类型:ImportError 例外价值:
没有名为后端的模块 异常位置:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py in import_module,第37行 Python可执行文件:/ usr / bin / python Python版本:2.7.6 Python路径:
[' /用户/ saraabi /站点/ django_testapp&#39 ;, ' /Library/Python/2.7/site-packages/pip-6.0.6-py2.7.egg' ;, ' /用户/ saraabi / django的干线&#39 ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload' ;, ' /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC' ;, ' /Library/Python/2.7/site-packages'] 服务器时间:星期四,2015年7月16日23:31:24 +0000环境:
请求方法:POST请求URL: http://localhost:8000/admin/login/?next=/admin/
Django版本:1.9.dev20150119161257 Python版本:2.7.6已安装 应用程序:(' django.contrib.admin',' django.contrib.auth', ' django.contrib.contenttypes',' django.contrib.sessions', ' django.contrib.messages',' django.contrib.staticfiles', ' testapp')已安装的中间件: (' django.contrib.sessions.middleware.SessionMiddleware&#39 ;, ' django.middleware.common.CommonMiddleware&#39 ;, ' django.middleware.csrf.CsrfViewMiddleware&#39 ;, ' django.contrib.auth.middleware.AuthenticationMiddleware&#39 ;, ' django.contrib.auth.middleware.SessionAuthenticationMiddleware&#39 ;, ' django.contrib.messages.middleware.MessageMiddleware&#39 ;, ' django.middleware.clickjacking.XFrameOptionsMiddleware&#39 ;, ' django.middleware.security.SecurityMiddleware&#39)
回溯:文件 " /Users/saraabi/django-trunk/django/core/handlers/base.py"在 get_response 131.response = wrapped_callback(request,* callback_args,** callback_kwargs)File" /Users/saraabi/django-trunk/django/views/decorators/cache.py"在 _wrapped_view_func 54. response = view_func(request,* args,** kwargs)File" /Users/saraabi/django-trunk/django/contrib/admin/sites.py"在登录 388.返回登录(请求,**默认值)文件" /Users/saraabi/django-trunk/django/views/decorators/debug.py"在 sensitive_post_parameters_wrapper 76. return view(request,* args,** kwargs)File" /Users/saraabi/django-trunk/django/utils/decorators.py"在 _wrapped_view 110.response = view_func(request,* args,** kwargs)File" /Users/saraabi/django-trunk/django/views/decorators/cache.py"在 _wrapped_view_func 54. response = view_func(request,* args,** kwargs)File" /Users/saraabi/django-trunk/django/contrib/auth/views.py"在登录 40.如果form.is_valid():File" /Users/saraabi/django-trunk/django/forms/forms.py"在is_valid 136. return self.is_bound而不是self.errors文件" /Users/saraabi/django-trunk/django/forms/forms.py"在错误 128. self.full_clean()File" /Users/saraabi/django-trunk/django/forms/forms.py"在full_clean 345. self._clean_form()File" /Users/saraabi/django-trunk/django/forms/forms.py"在_clean_form中 369. cleaning_data = self.clean()File" /Users/saraabi/django-trunk/django/contrib/auth/forms.py"在干净 165.密码=密码)文件" / Users / saraabi / django-trunk / django / contrib / auth / init .py"在 认证 60.对于后端,_get_backends中的backend_path(return_tuples = True):文件" / Users / saraabi / django-trunk / django / contrib / auth / init .py"在 _get_backends 27. backend = load_backend(backend_path)File" / Users / saraabi / django-trunk / django / contrib / auth / init .py"在 load_backend 21. return import_string(path)()File" /Users/saraabi/django-trunk/django/utils/module_loading.py"在 import_string 22. module = import_module(module_path)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/ init .py" 在import_module中 37. 导入(姓名)
异常类型:/ error / login /的ImportError异常值:否 名为后端的模块
答案 0 :(得分:0)
settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__) + '/../')
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
SITE_ID = 1
ROOT_URLCONF = 'apps.urls'
WSGI_APPLICATION = 'apps.wsgi.application'
TEMPLATE_DIRS = (
PROJECT_DIR + '/templates/',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
答案 1 :(得分:0)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'testapp',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'django_testapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'django_testapp.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTHENTICATION_BACKENDS = [
'testapp.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'