确保每次修改模板标签时都重新启动 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. VBO、VAO和EBO

    Vertex Buffer Object 对于经历过fixed pipeline的我来讲,VBO的出现对于渲染性能提升让人记忆深刻.完了,暴露年龄了~ //immediate mode glBegin ...

  2. VS中光标变成方块状,输入时会把光标覆盖的部分替换掉的解决方法

    按下键盘上的Insert键,切换为插入模式.

  3. volatile 的使用

    ① 编译器很聪明,会帮我们做些优化,比如: int a; a = 0; // 这句话可以优化掉,不影响 a 的结果 a = 1; ② 有时候编译器会自作聪明,比如: int *p = ioremap( ...

  4. jmeter自动停止监听--AutoStop Listener

    如下图:

  5. [bug] kibana:prevMsg":"Request Timeout after 3000ms

    ES启动问题,内存不足 https://blog.csdn.net/qq_40907977/article/details/104499178 修改ES启动内存 https://blog.csdn.n ...

  6. [Qt] 打包

    步骤: 1.release项目,生成exe文件 2.在命令行中使用windeployqt,将相关文件复制到exe文件所在文件夹 3.用Enigma Virtual Box打包所有文件 参考 https ...

  7. 优启通-PE启动盘制作工具 原版Win7系统安装超详细教程!!!!!

    https://www.jianshu.com/p/cd4abc9889b6 前期准备 原版Win7系统ISO映像文件 PE启动U盘或系统光盘(本教程以纯净无捆绑的优启通PE为示例) 优启通v3.3下 ...

  8. jolokia配置Java监控

    wget http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.6/jolokia-jvm-1.3.6- ...

  9. Sqli-labs-master通关解析(持续更新中。。。)

    大多情况下:SQL注入其实就是构造正确的mysql命令,让网页回显本不应该让我们看到的数据(如用户的账号和密码). 第一关-联合查询注入 查库 // 查看当前页面在的数据库 ?id=-1' union ...

  10. LTC3780 工作原理分析

    流程分析 当 CV调节 调节顺时针调节CV的时候 接入电路部分的电阻变大 Vosense变小 LTC内部的误差放大器 输出的变大 LTC内部逻辑调节 增大电压 我估计最终电压还是大约800mv左右 可 ...