gpt4 book ai didi

python - Django 属性错误 : 'module' object has no attribute 'is_usable'

转载 作者:太空宇宙 更新时间:2023-11-03 15:28:36 25 4
gpt4 key购买 nike

在 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'

最佳答案

看起来 Django 正在寻找一个可用的模板加载器,但在 settings.TEMPLATE_LOADERS 中发现了一些不符合模板加载器功能协议(protocol)的东西(简要描述 here。)

是否有可能您最近的更改之一是 settings.TEMPLATE_LOADERS 或自定义模板加载器?如果是后者,您的模板函数需要一个 is_usable 属性,大概设置为 True

关于python - Django 属性错误 : 'module' object has no attribute 'is_usable' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2941108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com