如果选择了某个布尔字段,我怎样才能在html页面上渲染django表单字段。
forms.py:
....
choose_encryption = forms.BooleanField(label='Would you like encryption?')
key1 = forms.CharField(widget=forms.PasswordInput)
key2 = forms.CharField(widget=forms.PasswordInput)
...
new_file.html:
....
<p> {{ form.choose_encryption }} </p>
when form.boolean_field becomes true:
<p> {{ form.key1 }} </p>
<p> {{ form.key2 }} </p>
....
是否有一个widget / attr可以在不重新加载页面或调用视图的情况下实现?
感谢