在Django中调用url时出现以下错误。 它之前正在工作,我想这与我做的一些意外变化有关,但我不知道它们是什么。
先谢谢你的帮助, 罗伯特
Environment:
Request Method: GET Request URL: http://localhost:8000/time/ Django Version: 1.2 Python Version: 2.6.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'djlearn.books'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')
Traceback: File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args,
**callback_kwargs) File "/Users/rhenru/Workspace/django/djlearn/src/djlearn/../djlearn/views.py" in current_datetime
16. return render_to_response('current_datetime.html',{'current_date':now,}) File "/Library/Python/2.6/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs) File "/Library/Python/2.6/site-packages/django/template/loader.py" in render_to_string
181. t = get_template(template_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in get_template
157. template, origin = find_template(template_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in find_template
128. loader = find_template_loader(loader_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in find_template_loader
111. if not func.is_usable:
Exception Type: AttributeError at /time/ Exception Value: 'module' object has no attribute 'is_usable'
答案 0 :(得分:4)
看起来Django正在寻找一个可用的模板加载器,但是在settings.TEMPLATE_LOADERS
中发现了一些不符合模板加载器功能协议的东西(简要描述here。)
您最近的更改之一可能是settings.TEMPLATE_LOADERS
还是自定义模板加载器?如果是后者,您的模板函数需要is_usable
属性,大概设置为True
。