在Python的Django框架中为代码添加注释的方法
作者:goldensun 时间:2023-09-25 07:24:21
就像HTML或者Python,Django模板语言同样提供代码注释。 注释使用 {# #} :
{# This is a comment #}
注释的内容不会在模板渲染时输出。
用这种语法的注释不能跨越多行。 这个限制是为了提高模板解析的性能。 在下面这个模板中,输出结果和模板本身是 完全一样的(也就是说,注释标签并没有被解析为注释):
This is a {# this is not
a comment #}
test.
如果要实现多行注释,可以使用`` {% comment %}`` 模板标签,就像这样:
{% comment %}
This is a
multi-line comment.
{% endcomment %}
标签:Django,代码
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python函数定义及传参方式详解(4种)
2022-08-16 14:39:08
微信小程序picker组件简单用法示例
2023-07-23 10:49:32
![](https://img.aspxhome.com/file/2023/1/55921_0s.gif)
python代码实现五子棋游戏
2021-04-18 01:20:48
![](https://img.aspxhome.com/file/2023/6/112586_0s.jpg)
python数据可视化绘制世界人口地图
2022-04-27 21:31:31
![](https://img.aspxhome.com/file/2023/5/102895_0s.png)
python利用proxybroker构建爬虫免费IP代理池的实现
2021-10-25 21:18:25
![](https://img.aspxhome.com/file/2023/9/130629_0s.jpg)
python 动态规划问题解析(背包问题和最长公共子串)
2021-01-21 14:17:24
![](https://img.aspxhome.com/file/2023/7/130537_0s.png)
Python使用os模块实现更高效地读写文件
2021-08-11 00:41:39
![](https://img.aspxhome.com/file/2023/3/117923_0s.png)
Python采集王者皮肤图片实战示例
2021-08-02 12:09:23
![](https://img.aspxhome.com/file/2023/7/106967_0s.jpg)
按钮的反馈
2009-01-01 20:06:00
![](https://img.aspxhome.com/file/UploadPic/20091/1/1-60s.jpg)
python内置堆的具体实现
2022-12-18 08:39:43
![](https://img.aspxhome.com/file/2023/9/105589_0s.png)
Web性能优化系列 10个提升JavaScript性能的技巧
2024-05-28 15:40:37
MySQL下载安装及完美卸载的详细过程
2024-01-17 18:39:17
![](https://img.aspxhome.com/file/2023/4/71124_0s.png)
Windows11使用Cpython 编译文件报错 error: Unable to find vcvarsall.bat 完美解决方法
2021-03-14 19:03:19
![](https://img.aspxhome.com/file/2023/6/131446_0s.jpg)
python 提高开发效率的5个小技巧
2022-05-11 00:55:09
Python实现求最大公约数及判断素数的方法
2021-06-13 02:20:20
用sql脚本创建sqlserver数据库触发器范例语句
2024-01-27 16:42:14
详解Mybatis逆向工程中使用Mysql8.0版本驱动遇到的问题
2024-01-16 16:48:19
python使用Qt界面以及逻辑实现方法
2023-10-23 23:28:09
![](https://img.aspxhome.com/file/2023/4/87644_0s.png)
Python 一行代码能实现丧心病狂的功能
2023-07-25 08:32:17
![](https://img.aspxhome.com/file/2023/8/61428_0s.png)
Python实现的读取/更改/写入xml文件操作示例
2023-06-05 05:16:42