我正在尝试使用此表单从列表中过滤唯一性:
class SpecForm(ModelForm):
a = Doctors_list.objects.values_list('specialty', flat=True)
unique = {z: i for i, z in a}
qs = Doctors_list.objects.filter(id__in=unique.values())
specialty = forms.ModelChoiceField(queryset=qs)
class Meta:
model = Doctors_list
一切对我来说似乎都是正确的,但我收到了这个错误:too many values to unpack
任何提示?