关于Django Models CharField 参数说明
作者:pythonLs 时间:2021-05-01 04:54:12
如下所示:
depot_name = models.CharField(
u'设备库房名称',
blank=True,
max_length=20,
null=True,
# default='',
help_text='显示在下方吗',
)
在这里u'设备库房名称‘,是将depot_name这个英文名重写,blank=True是允许表单验证为空,null=True是允许数据库这个值为空,
help_text是提示信息v在这里u'设备库房名称‘,是将depot_name这个英文名重写,blank=True是允许表单验证为空,null=True是允许数据库这个值为空,help_text是提示信息
补充知识:Django-html中显示后台数据中CharField(choices=())字段类型的数据
1.后台代码:
class Course(models.Model):
degree = models.CharField(choices=(('cj',u'初级'),('zj',u'中级'),('gj',u'高级')),max_length=2,verbose_name=u'难度')
2.html中:
第一种显示方式(cj、zj、gj):
<span class="fl">难度:<i class="key">{{ curent_org.degree }}</i></span>
第二种显示方式(初级、中级、高级):
<span class="fl">难度:<i class="key">{{ curent_org.get_degree_display }}</i></span>
来源:https://blog.csdn.net/weixin_39255894/article/details/78664401
标签:Django,Models,CharField
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
在阿里云服务器上配置CentOS+Nginx+Python+Flask环境
2023-07-26 09:47:46
一个简单的ASP生成HTML分页程序
2009-07-05 18:32:00
关于JS中变量的显式声明和隐式声明
2008-10-06 13:22:00
python3爬取淘宝信息代码分析
2021-05-03 04:59:11
opencv python统计及绘制直方图的方法
2021-12-27 21:52:45
![](https://img.aspxhome.com/file/2023/0/81450_0s.png)
Python实现线性判别分析(LDA)的MATLAB方式
2022-07-21 02:38:34
![](https://img.aspxhome.com/file/2023/6/114726_0s.jpg)
echarts柱状图坐标轴内容显示不全的两种解决办法
2023-09-06 03:57:34
![](https://img.aspxhome.com/file/2023/2/56122_0s.png)
一些让Python代码简洁的实用技巧总结
2022-02-06 11:03:25
XML 增、删、改和查示例
2008-09-05 17:12:00
Python基于回溯法子集树模板实现图的遍历功能示例
2021-10-29 15:20:31
![](https://img.aspxhome.com/file/2023/9/102829_0s.jpg)
如何解决MySQL的客户端不支持鉴定协议
2008-11-27 17:10:00
匹配 IP 地址与域名的正则表达式
2023-06-17 05:55:48
Python全栈之队列详解
2022-10-12 07:51:33
![](https://img.aspxhome.com/file/2023/5/85385_0s.png)
DIV+CSS常见错误及解决方法
2008-04-25 22:46:00
Python列表计数及插入实例
2023-05-26 23:41:12
python输出指定月份日历的方法
2022-11-27 11:39:18
django 外键model的互相读取方法
2021-06-16 20:54:51
python使用openpyxl操作excel的方法步骤
2022-09-30 20:59:24
![](https://img.aspxhome.com/file/2023/6/101446_0s.jpg)
Python实现自动装机功能案例分析
2022-05-16 12:35:48
golang 实现tcp server端和client端,并计算RTT时间操作
2023-08-30 14:12:49