报错代码:

'selffilter' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
static
staticfiles
tz

解决方法:

错误可能:

1. 在你的app目录下新建templatetags文件夹里没创建__init__.py定义为包

2. 程序编写问题

在templatetags下创建myfilter.py 文件

html文件中

3.settings.py未设置

上面是摘自https://blog.csdn.net/qq_40326481/article/details/80342480

补充其他的方法:

不知道是我的版本问题还是必须的这么写,我在检查了上面的几种方法之后还是报相同的错误,找了好久,终于找到了出错地地方

原来的代码:

from django import template
registor = template.Library() #注册 #告诉Djiango这个函数的名字是mmd
@registor.filter(name="mmd")
def mmd1(arg,name):
return "%s亲了%s一下"%(arg,name)

修改:由于我的单词写成了registor,所以一直报错。

把单词改为register就不报错了,难道统一了入口?

from django import template
register = template.Library() #注册 #告诉Djiango这个函数的名字是mmd
@register.filter(name="mmd")
def mmd1(arg,name):
return "%s亲了%s一下"%(arg,name)

注意在调用函数的时候,

{% load selffilter %}
<p>{{ dict.dxx|mmd:"xpg" }}</p>

一定不要加上空格。

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

  1. 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 ...

  2. 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 ...

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

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

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

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

  5. 08:'my_tag' is not a registered tag library. Must be one of

    确保每次修改模板标签时都重新启动 Django 开发服务器(或确保它自己重新启动).如果服务器没有重新启动,Django 将不会注册标签. 从 django 1.9 开始,您可以在如下设置中加载这些新 ...

  6. 自定义标签 与 JSTL(JSP Standard Tag Library)

    1.自定义标签 [理解]     [1]简介            > 在JSP2.0以后,在jsp页面中不建议使用脚本片段<% %>和JSP表达式<%= %>     ...

  7. 报错:严重: 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 [ ...

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

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

  9. SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-003- SPRING的GENERAL TAG LIBRARY简介及用<s:message>和ReloadableResourceBundleMessageSource实现国际化

    一. SPRING支持的GENERAL TAG LIBRARY 1. 二.用<s:message>和ReloadableResourceBundleMessageSource实现国际化 1 ...

随机推荐

  1. jquery 获取jquery对象的标签类型

    //jquery 对象 $("#"+控件id)[0] //查看控件类型  $("#"+控件id)[0].type 实例1: < select id=&qu ...

  2. SSM-Spring-19:Spring中JdbcTemplate

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- Spring自带一个ORM持久化框架JdbcTemplate,他可以说是jdbc的加强版,但是对最细微的控制肯 ...

  3. 超越Ctrl+S保存页面所有资源

    如何抓取页面所有内容 基本需求 抓取页面所有内容主要包括一下内容: 页面内元素 页面元素包含服务端直接返回的元素,动态构建的元素 页面内所有资源 页面所有资源包含本页面所在域资源以及第三方域资源,同主 ...

  4. union 的两个用处

    1 节约内存: 这一功能可以参考我的其它博文: https://i.cnblogs.com/EditPosts.aspx?postid=8545190&update=1 2 测试机器大小端: ...

  5. Spring Boot 2.0 教程 - 配置详解

    Spring Boot 可以通过properties文件,YAML文件,环境变量和命令行参数进行配置.属性值可以通过,@Value注解,Environment或者ConfigurationProper ...

  6. yii2.0 app上集成支付宝支付

    1.首先从支付宝官网下载支付宝app支付sdk 地址 : https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.hLEa5O&a ...

  7. WIN10怎么安装SQL server2000数据库

    怎样在win10下安装sql2000数据库 1.安装之前先确认自己的Windows10是64位的还是32位的 2.替换对应的系统文件SQLUNIRL.dll 此时你可能会遇到,没有权限替换文件或重命名 ...

  8. NET Core 跨平台执行命令、脚本

    一.前言 我们可能会遇到需要在程序中执行一些系统命令,来获取一些信息:或者调用shell脚本..NET Core 目前已经可以跨平台执行,那么它如何跨平台执行命令呢,请看下面的讲解. 二.Proces ...

  9. java基础小项目练习之1----3天做出飞机大战

    Shoot射击游戏第一天一. 关键问题(理论):1. 简述FlyingObject.Enemy.Award.Airplane.Bee.Bullet.Hero之间的继承与实现关系2. 简述Hero类构造 ...

  10. consoleWriter.go

    package blog4go import ( "fmt" "os" "time" ) // ConsoleWriter is a con ...