我有一个包含3个字段的表单,我想根据用户在第二个字段中提供的数据,从最后两个字段(下拉列表)中禁用一些项目。
forms.py
class EditForm(forms.Form):
status = [('pending','Pending'),
('published','Published'),
('ready to upload','Ready to upload'),
('uploaded but not published','Uploaded but not published')]
p_status = [('pending','Pending'),
('approved', 'Approved'),
('rejected','Rejected')]
link = forms.URLField(required=False,widget=forms.URLInput(attrs={'class':''}))
promotion_status = forms.CharField(widget=forms.Select(choices=status))
partner_status = forms.CharField(widget=forms.Select(choices=p_status))
如果用户填写了链接,则禁用状态中的“发布”和p_status中的“拒绝”。
我尝试了if else语句,但没有用。
plz帮助