1. 介绍
在某些情况下我们需要在页面中定义一个隐藏对象,我们来看看Django中隐藏对象如何处理吧.
2. Model定义
Models.py中定义了一个隐藏的对象id_user
'id_user':forms.TextInput(attrs={'class':'form'control','type':'hidden'})
3. Template中的处理
- 隐藏对象的处理
{% for item in form.hidden_fields %}
{{item}}
{% endfor %}
- 非隐藏对象的处理
{% for item in form.visible_fields %}
<div class="form-group">
<label class="control-label col-md-2" style="text-align:right" >{{item.label}} <font style="color:red"> * </font></label>
<div class="col-md-5">
{{item}}
</div>
<font style="color:red">{{item.errors}}</font>
</div>
{% endfor %}
文章最后更新时间: 2017年05月16日 18:56:46
分类文章统计
Django(5)
Flask(1)
Python常见错误(3)
Python基础(10)
linux排障(4)
虚拟化(1)
Consul(3)
Linux基础(6)
shell(11)
oracle(10)
MySQL(64)
ProxySQL(7)
SequoiaDB(2)
TiDB(4)
Redis(2)
常用软件(2)
硬件排障(2)
HTML(1)
JavaScript(1)
我们的作品(18)
windows(1)
总结(1)
按年文章统计
2013(43)
2014(19)
2015(25)
2016(6)
2017(30)
2018(7)
2019(17)
2020(4)
2021(4)
2023(1)
2024(3)
老版入口
亲,扫我吧!

友情链接
飞哥的:imbusy.me/
冰川的:www.mindg.cn
海洋的:hiaero.net
宏斌的:techindeep.com
若水的:nosa.me
段郎的:sixther.me
肥客联邦:fk68.net