确保每次修改模板标签时都重新启动 Django 开发服务器(或确保它自己重新启动)。如果服务器没有重新启动,Django 将不会注册标签。

从 django 1.9 开始,您可以在如下设置中加载这些新标签/过滤器:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'app.apptemplates.load_setting', ], 'libraries':{
'my_templatetag': 'app.templatetags.my_templatetag', }
},
},
]

确保您没有遗漏以下任何步骤:

  1. 在您的应用程序文件夹中创建一个与models.py 和views.py 处于同一级别的名为“templatetags”的文件夹

  2. 您的应用程序必须位于 settings.py 中的 INSTALLED_APPS 中

  3. templatetags 文件夹必须有 __init__.py

  4. 重启django服务器

08:'my_tag' is not a registered tag library. Must be one of的更多相关文章

  1. 关于'selffilter' is not a registered tag library. Must be one of:

    报错代码: 'selffilter' is not a registered tag library. Must be one of: admin_list admin_modify admin_st ...

  2. django.template.exceptions.TemplateSyntaxError: 'article_tags' is not a registered tag library.

    django.template.exceptions.TemplateSyntaxError: 'article_tags' is not a registered tag library. Must ...

  3. django.template.exceptions.TemplateSyntaxError: 'static' is not a registered tag library. Must be one of:

    在访问web页面时报错,详细日志如下: django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registere ...

  4. 【django-simpleui】‘simpletags‘ is not a registered tag library报错的解决方法

    1:创建  templatetags文件夹 2:创建simpletags.py文件将内容粘贴进去,在下面 3:setting.py添加文件指定: 1 TEMPLATES = [ 2 { 3 'BACK ...

  5. Django 自定义模板标签 报错django.template.exceptions.TemplateSyntaxError: '####' is not a registered tag library. Must be one of:

    我写代码遇到这个错误,但是发现程序没有写错,好像是程序有缓存,重新运行几次就好了. 自定义模板标签,可以不用写views,url直接通过自定义函数把变量传给模板. 具体实现: 1.在app下新建Pyt ...

  6. 报错:严重: Servlet.service() for servlet [jsp] in context with path [/20161116-Struts2-6] threw exception [/index.jsp (line: 13, column: 20) No tag "textfiled" defined in tag library imported with prefix

    严重: Servlet.service() for servlet [jsp] in context with path [/20161116-Struts2-6] threw exception [ ...

  7. JSTL的全称:JSP Standard Tag Library, jsp 标准标签库

    JSTL的全称:JSP Standard Tag Library, jsp 标准标签库 JSTL的作用     提供给Java web开发人员一个标准通过的标签函数库和EL来取代传统直接在页面上嵌入j ...

  8. 使用jstl报错:Can not find the tag library descriptor for “http://java.sun.com/jstl/core”

    使用jstl报错:Can not find the tag library descriptor for “http://java.sun.com/jstl/core” 出现这个错误的原因是项目中没有 ...

  9. Effective C++ 条款08:别让异常逃离析构函数

    1.别让异常逃离析构函数的原因 <Effective C++>第三版中条款08建议不要在析构函数中抛出异常,原因是C++异常机制不能同时处理两个或两个以上的异常.多个异常同时存在的情况下, ...

随机推荐

  1. Asp.NetCore Web开发之ADO.Net

     Asp.NetCore可以说是.Net平台开发网站的一大利器,最近的一大段时间,就要跟大家分享,如何使用这一利器开发网站项目. 要学习网站开发,首先要学习如何使用ADO.Net进行数据库数据的增删改 ...

  2. VS里的 代码片段(Code snippet)很有用,制作也很简单

    工欲善其事必先利其器,而 Visual Studio 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...

  3. 有哪些适用于律师事务所的CRM系统?

    中国的经济发展和政治稳定给律师行业带来了巨大的空间.而互联网的发展也让律师事务所遍地开花.如何在大大小小的律所中脱颖而出,是每个律所都迫切需要解决的问题.为了让您的律师事务所在激烈的竞争中脱颖而出,今 ...

  4. 网络编程-UDP的服务器和客户端----keep on going never give up

    1 //**************************************服务器********************************************** 2 #inclu ...

  5. 定义私有属性: *String name; * int age; * String gender; * int salary; Date hiredate;//入职时间

    import java.text.SimpleDateFormat; import java.util.Date; /** * 定义私有属性: * String name; * int age; * ...

  6. javaWeb——jsp

    JavaBean 提供一个默认的无参构造函数 需要被序列化并且实现了 Serializable 接口 可能有一系列可读写属性 可能有一系列的 getter 或 setter 方法

  7. linux自动化交互脚本expect详解set timeout 5是 意思是在expect语句中,5s后超时,不再作出选择。

    linux自动化交互脚本expect详解  更新时间:2020年10月21日 10:13:20   作者:lendsomething     这篇文章主要介绍了linux自动化交互脚本expect的相 ...

  8. Docker——JVM 感知容器的 CPU 和 Memory 资源限制

    前言 对于那些在Java应用程序中使用Docker的CPU和内存限制的人来说,可能会遇到一些挑战.特别是CPU限制,因为JVM在内部透明地设置GC线程和JIT编译器线程的数量. 这些可以通过命令行选项 ...

  9. suse11sp3、suse12 安装 zabbix-agent

    1.添加repo源 suse11SP3zypper addrepo http://download.opensuse.org/repositories/server:/monitoring/SLE_1 ...

  10. 运维常用shell脚本一(系统指标巡检、自动创建用户、跳板机)

    一.系统指标巡检脚本 #!/bin/bash menu(){ cat <<EOF +---------------------------------------------+ | 日常巡 ...