Django属性错误:'function'对象没有属性'is_usable'
我正在建立一个Django博客。我跟着these instructions,我收到以下错误:
Environment:
Request Method: GET
Request URL: http://url.com/
Django Version: 1.6.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'divinare',
'rest_framework',
'django_facebook',
'django.contrib.auth')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
139. response = response.render()
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/response.py" in render
105. self.content = self.rendered_content
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
80. template = self.resolve_template(self.template_name)
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/response.py" in resolve_template
56. return loader.select_template(template)
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/loader.py" in select_template
180. return get_template(template_name)
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/loader.py" in get_template
138. template, origin = find_template(template_name)
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/loader.py" in find_template
121. loader = find_template_loader(loader_name)
File "/home/spencer/webapps/hello_django/local/lib/python2.7/site-packages/django/template/loader.py" in find_template_loader
104. if not func.is_usable:
Exception Type: AttributeError at /
Exception Value: 'function' object has no attribute 'is_usable'
中间件:
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
模板加载器:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.contrib.auth.context_processors.auth',
# 'django.template.loaders.eggs.Loader',
)
对导致错误的原因的任何见解都会非常有用。
答案 0 :(得分:1)
你的问题几乎可以肯定,你有" django.contrib.auth.context_processors.auth"在TEMPLATE_LOADERS
设置中。顾名思义,这是一个上下文处理器,而不是模板加载器 - 它应该进入TEMPLATE_CONTEXT_PROCESSORS
。