解决Django layui {{}}冲突的问题
作者:djshichaoren 时间:2023-07-23 15:22:18
layui的table的自定义模板需要用到{{}},但是和Django的{{}}冲突了,layui的{{}}失效了
解决方法:从Django 1.5开始,支持{% verbatim %}标签(verbatim的意思是逐字翻译的,字面意思的),Django不会渲染verbatim标签包裹的内容
<table class="layui-table" lay-data="{ height:332, url:'/get_shop_table_msg/', page:false, id:'idTest'}"
lay-filter="demo">
<thead>
<tr>
<th lay-data="{checkbox:true, fixed: true}"></th>
<th lay-data="{field:'shop_id', width:80, sort: true, fixed: true}">店铺ID</th>
<th lay-data="{field:'shop_name',width:200, sort: true}">店铺名称</th>
<th lay-data="{field:'shop_url', width:500, templet:'#a_shop_url'}">店铺Url</th>
<th lay-data="{fixed: 'right', width:160, align:'center', toolbar: '#barDemo'}"></th>
</tr>
</thead>
</table>
<script type="text/html" id="a_shop_url">
<a href="{% verbatim %}{{ d.shop_url }}{% endverbatim %}" rel="external nofollow" class="layui-table-link" target="_blank"> {% verbatim %}{{ d.shop_url }}{% endverbatim %} </a>
</script>
将layui用到的{{}},用
{% verbatim %}{% endverbatim %}
包起来就可以了。
来源:https://blog.csdn.net/djshichaoren/article/details/78313914
标签:Django,layui,{{}},冲突
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python在字符串中处理html和xml的方法
2023-09-01 21:19:08
python合并RepeatMasker预测结果中染色体的overlap区域
2021-12-28 21:29:35
![](https://img.aspxhome.com/file/2023/7/127867_0s.jpg)
python自动化测试三部曲之request+django实现接口测试
2023-07-11 05:12:00
![](https://img.aspxhome.com/file/2023/3/114513_0s.png)
tensorflow 环境变量设置方式
2021-10-09 16:53:51
![](https://img.aspxhome.com/file/2023/5/99115_0s.jpg)
python3.6 实现AES加密的示例(pyCryptodome)
2022-07-05 08:17:08
![](https://img.aspxhome.com/file/2023/4/82764_0s.png)
正则表达式简介
2007-08-12 18:01:00
Python 分析Nginx访问日志并保存到MySQL数据库实例
2024-01-22 08:43:23
python sorted方法和列表使用解析
2021-07-09 05:32:41
![](https://img.aspxhome.com/file/2023/5/103325_0s.png)
奇妙的Javascript图片放大镜
2024-04-30 08:51:22
vue 需求 data中的数据之间的调用操作
2023-07-02 16:52:03
![](https://img.aspxhome.com/file/2023/7/139807_0s.jpg)
python爬虫_实现校园网自动重连脚本的教程
2021-10-12 22:56:37
![](https://img.aspxhome.com/file/2023/5/123695_0s.jpg)
Python多叉树的构造及取出节点数据(treelib)的方法
2021-11-07 05:00:16
Python利用pywin32实现自动操作电脑
2024-01-03 03:35:59
![](https://img.aspxhome.com/file/2023/3/110253_0s.gif)
谈谈XHTML中CDATA
2007-09-17 12:45:00
PyTorch中Tensor的数据统计示例
2021-03-05 01:04:53
深入解析Vue源码实例挂载与编译流程实现思路详解
2024-05-11 09:11:41
![](https://img.aspxhome.com/file/2023/3/126533_0s.png)
css闭合浮动元素
2008-05-09 19:41:00
Oracle 日期的一些简单使用
2009-08-05 20:42:00
vue2 设置router-view默认路径的实例
2023-07-02 17:03:02
基于python利用Pyecharts使高清图片导出并在PPT中动态展示
2021-02-23 13:02:39
![](https://img.aspxhome.com/file/2023/7/131607_0s.png)