Django forms.Choicefield获得选择选择

时间:2015-08-26 13:39:59

标签: python django django-forms choicefield

我需要为if / else语句获取forms.Choicefield的选定值,根据所选值生成另一个forms.Choicefield

forms.py:

class ReceiverForm(forms.Form):
receivers = forms.ChoiceField(choices=db_mails(), required=True, label='Receivers')

if db_certs(<- selected value from receivers ChoiceField ->):
    print "cert found"
    encryption = forms.ChoiceField(choices=EncryptionChoiceAll, initial='smime_mail', required=True, label='Encryption')
else:
    print "no cert found"
    encryption = forms.ChoiceField(choices=EncryptionChoiceNoCert, initial='smime_mail', required=True, label='Encryption')

db_mails()db_certs(mail)正在按预期工作

有没有办法在forms.py中实现我所需要的,或者我对设计完全错了?

0 个答案:

没有答案
相关问题