如何访问views.py中的ChoiceField选项,以便可以基于它打印不同的输出? (我尝试了下面的代码,但它似乎无法正常工作,我不知道哪里出了问题)
forms.py
class BeamForm(forms.Form):
CHOICES = (('Add on', 'Add on'),('Reset', 'Reset'),)
field = forms.ChoiceField(choices=CHOICES)
views.py
from . import forms
if forms.BeamForm.field == 'Add on':
print("Option is add on")
elif forms.BeamForm.field == 'Reset'
print("Option is Reset")
else:
print("nothing")