我想获得选择了value1的人的电子邮件列表。这是我的代码:
views.py
if form.is_valid():
email = form.cleaned_data['email']
option = request.POST.getlist('my_field')
new_user = form.save(email, option)
list = Vartotojas.objects.filter(option=u"Value1").values_list("email", flat=True)
# Here I am trying to get list of emails, who chose Value 1
forms.py
email = forms.EmailField(max_length=100)
my_field = forms.MultipleChoiceField(choices=(('Value1','Value1'),('Value2','Value2')), widget=forms.CheckboxSelectMultiple())
def save(self, email, option):
mymodel = Vartotojas(
email=email,
option = option,
)
mymodel.save()
models.py
option = models.CharField(max_length=30)
然而,在我收到空列表的电子邮件列表中。我的错误在哪里?