关于'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_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:的更多相关文章
- 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 ...
- 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 ...
- 【django-simpleui】‘simpletags‘ is not a registered tag library报错的解决方法
1:创建 templatetags文件夹 2:创建simpletags.py文件将内容粘贴进去,在下面 3:setting.py添加文件指定: 1 TEMPLATES = [ 2 { 3 'BACK ...
- Django 自定义模板标签 报错django.template.exceptions.TemplateSyntaxError: '####' is not a registered tag library. Must be one of:
我写代码遇到这个错误,但是发现程序没有写错,好像是程序有缓存,重新运行几次就好了. 自定义模板标签,可以不用写views,url直接通过自定义函数把变量传给模板. 具体实现: 1.在app下新建Pyt ...
- 08:'my_tag' is not a registered tag library. Must be one of
确保每次修改模板标签时都重新启动 Django 开发服务器(或确保它自己重新启动).如果服务器没有重新启动,Django 将不会注册标签. 从 django 1.9 开始,您可以在如下设置中加载这些新 ...
- 自定义标签 与 JSTL(JSP Standard Tag Library)
1.自定义标签 [理解] [1]简介 > 在JSP2.0以后,在jsp页面中不建议使用脚本片段<% %>和JSP表达式<%= %> ...
- 报错:严重: 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 [ ...
- JSTL的全称:JSP Standard Tag Library, jsp 标准标签库
JSTL的全称:JSP Standard Tag Library, jsp 标准标签库 JSTL的作用 提供给Java web开发人员一个标准通过的标签函数库和EL来取代传统直接在页面上嵌入j ...
- SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-003- SPRING的GENERAL TAG LIBRARY简介及用<s:message>和ReloadableResourceBundleMessageSource实现国际化
一. SPRING支持的GENERAL TAG LIBRARY 1. 二.用<s:message>和ReloadableResourceBundleMessageSource实现国际化 1 ...
随机推荐
- maven 编译出错Fatal error compiling: 无效的目标发行版: 1.8 -> [Help 1] 解决办法
这几天在为公司项目搭建一个后台框架,使用的是eclipse-Mars自带的maven插件,在maven进行编译的时候,出现Fatal error compiling: 无效的目标发行版: 1.8 -& ...
- Linux时间子系统之五:低分辨率定时器的原理和实现
专题文档汇总目录 Notes:低精度timer在内核中的数据结构以及API接口:低精度timer精巧高效的分组,使用cascade进行定时器移位,组内Timer FIFO:低精度Timer的初始化流程 ...
- vue项目如何刷新当前页面
1.场景 在处理列表时,常常有删除一条数据或者新增数据之后需要重新刷新当前页面的需求. 2.遇到的问题 1. 用vue-router重新路由到当前页面,页面是不进行刷新的 2.采用window.rel ...
- UsernamePasswordAuthenticationToken
UsernamePasswordAuthenticationToken继承AbstractAuthenticationToken实现Authentication所以当在页面中输入用户名和密码之后首先会 ...
- React从入门到放弃之前奏(2):React简介
本系列将尽可能使用ES6(ES2015)语法.所以均在上节webpack的基础上做开发. React是Facebook开发的一款JS库,因为基于Virtual DOM,所以响应速度快,以及支持跨平台. ...
- 写给小前端er的nodejs,mongodb后端小攻略~ (windows系统~)
一.写在前面 迫于学校的压力,研二上准备回学校做实验发论文了,感觉真的没意思,这几天学着搞搞后端,踩了很多坑,整理一下这几天的坑以免以后再犯! 二.本文主要内容(由于是面向前端同学的,所以前端的内容就 ...
- 在centos上面安装phantomjs
在opt目录下创建phantomjs文件夹 mkdir -p /opt/phantomjs 把phantomjs解压出来的的文件放到/opt/phantomjs下面 建立软链接 ln -s /opt/ ...
- Hadoop问题:DataNode进程不见了
DataNode进程不见了 问题描述 最近配置Hadoop的时候出现了这么一个现象,启动之后,使用jps命令之后是这样的: 看不到DataNode进程,但是能够正常的工作,是不是很神奇啊? 在一番 ...
- Python&Appium实现滑动引导页进入APP
最近在研究安卓APP的自动化测试.首先遇到的问题是,当一个session建立的时候,最先进入的是欢迎页和引导页,引导页有三张,最后一张上显示"enter"按钮,点击才能进入主界面. ...
- Python中的turtle初探
turtle Python自带了一个turtle库,就像名字turtle说的那样,你可以创建一个turtle,然后这个turtle可以前进,后退,左转,这个turtle有一条尾巴,能够放下和抬起,当尾 ...