forms - Newbie Django filter uniques 2 many values -
i trying filter uniques list form:
class specform(modelform): = doctors_list.objects.values_list('specialty', flat=true) unique = {z: i, z in a} qs = doctors_list.objects.filter(id__in=unique.values()) specialty = forms.modelchoicefield(queryset=qs) class meta: model = doctors_list
everything seems correct me, error: too many values unpack
any hints?
i think correct statement should this:
unique = {z: in a}
are trying put values dictionary? yield list:
unique = [ in ]
if go this, have remove .values()
in qs = doctors_list.objects.filter(id__in=unique.values())
leaving this:
qs = doctors_list.objects.filter(id__in=unique)
what's going on here brackets in first approach you're creating dictionary 1 key , list value of key. when issue .values()
list dictionary's values. it's pointless use dictionary.
with second approach list directly.
hope helps.
Comments
Post a Comment