当前位置: 首页 > 工具软件 > staticfiles > 使用案例 >

Django{% load staticfiles %}->{% load static %}

姚俊材
2023-12-01

Internal Server Error: /
Traceback (most recent call last):
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\defaulttags.py", line 1034, in find_library
    return parser.libraries[name]
KeyError: 'staticfiles'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "D:\python\pycharm\work\ComputeDemo\app\views.py", line 24, in home
    'app/home.html',
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\backends\django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\engine.py", line 143, in get_template
    template, origin = self.find_template(template_name)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\engine.py", line 125, in find_template
    template = loader.get_template(name, skip=skip)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\loaders\base.py", line 30, in get_template
    contents, origin, origin.template_name, self.engine,
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\base.py", line 155, in __init__
    self.nodelist = self.compile_nodelist()
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\base.py", line 193, in compile_nodelist
    return parser.parse()
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\base.py", line 478, in parse
    raise self.error(token, e)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\base.py", line 476, in parse
    compiled_result = compile_func(self, token)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\defaulttags.py", line 1091, in load
    lib = find_library(parser, name)
  File "D:\python\abaconda3\anzhuang\lib\site-packages\django\template\defaulttags.py", line 1038, in find_library
    name, "\n".join(sorted(parser.libraries)),
django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
[08/Apr/2021 09:33:48] "GET / HTTP/1.1" 500 142342
Not Found: /favicon.ico
[08/Apr/2021 09:33:48] "GET /favicon.ico HTTP/1.1" 404 2135


{% load staticfiles %} {% load adminstatic %} 是在 Django 2.1的方法, 在 Django 3.0已经修改了

改为{% load static %}

 

 类似资料: