Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 动态修改模板中的Django表单_Html_Django_Django Forms_Django Templates - Fatal编程技术网

Html 动态修改模板中的Django表单

Html 动态修改模板中的Django表单,html,django,django-forms,django-templates,Html,Django,Django Forms,Django Templates,我正在一个名为channels.html的页面中显示数据库中的100个对象 在一个名为“is_new”的复选框字段中,我能够从数据库中检索特定行的数据 channels.html {% for each_channel in channels_list %} ..... ....... other elements..... <td id="is_new"> **Attention here:{{form.is_new.value}} //--> I nee

我正在一个名为channels.html的页面中显示数据库中的100个对象

在一个名为“is_new”的复选框字段中,我能够从数据库中检索特定行的数据

channels.html

{% for each_channel in channels_list %}
    .....
     ....... other elements.....

<td id="is_new">
**Attention here:{{form.is_new.value}} //--> I need to modify this **
我可以用模板做吗?谢谢


我正在使用Django 1.5。

@GwynBleidD您能看看这个吗。@duffn,请检查一下,有人能回答这个问题吗?
// If the DB value is 1 then set the "yes" as checked and "No" as unchecked.  
// Set "Yes" as checked.

{% if each_channel.is_new%}
<span class="text-success" for="id_is_new_0">
<input id="id_is_new1_{{each_channel.usid}}" class="id_is_new"  name="is_new{{each_channel.usid}}" type="radio" value="1"checked="true"> Yes</span>

**// set "NO" unchecked**
<span for="id_is_new_1">
<input id="id_is_new0_{{each_channel.usid}}" class="id_is_new" name="is_new{{each_channel.usid}}" type="radio" value="0"> No</span>

*// Vice versa - If the DB value is 0, then do the vice versa.* 

{%else%}

**// Set "Yes" Unchecked.** 
<span for="id_is_new_0">
<input id="id_is_new1_{{each_channel.usid}}" class="id_is_new" name="is_new{{each_channel.usid}}" type="radio" value="1"> Yes</span>

**// Set "NO" Checked**
<span class="text-danger"  for="id_is_new_1">
<input id="id_is_new0_{{each_channel.usid}}" class="id_is_new" name="is_new{{each_channel.usid}}"type="radio" value="0" checked="True"> No</span>

{%endif%}
</td >
IF MY DB Value is THIS : 
Change my Form value, ID, Name to XXX

ELSE:
Change my Form value, ID, Name to YYY.