django.template.exceptions.TemplateSyntaxError: staticfiles is not a registered tag library. 问题解决

问题描述

Django 在加载静态文件时报了一个错误

django.template.exceptions.TemplateSyntaxError: staticfiles is not a registered tag library.

导致加载不出来 html 页面

问题解决

把模板文件(即 html 文件)中的

1
2
3
{% load staticfiles %}
{% load static from staticfiles %}
{% load admin_static %}

改成

1
{% load static %}

按:出现这样原因其实是版本的问题,现在用的是 Django 3.0 版本,而之前则是 Django 2.0。


版权声明: 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!