我有一个Django表单类,该类生成到前端的动态表单字段。我想通过使用Java脚本执行诸如启用,禁用,隐藏,显示等操作。只想控制Django动态表单js。
这是我的django表格
class SetFeatureForm(forms.Form):
def __init__(self, project=None, *args, **kwargs):
super(SetFeatureForm, self).__init__(*args, **kwargs)
if project:
choices = [(column,column) for column in pd.read_csv(project.file.path).columns]
self.fields['feature'] = forms.MultipleChoiceField(choices=choices, required=True, )
self.fields['feature'].widget.attrs['size']=len(choices)
for _,choice in choices:
self.fields[choice] = forms.ChoiceField( choices=DATA_TYPE.items())
有什么办法吗?