[Answer]-Newbie Django filter uniques 2 many values

1👍

I think the correct statement should be this:

unique = {z: i for i in a}

Are you specifically trying to put those values into a dictionary? This will yield a list:

unique = [ i for i in a ]

If you go with this, you will have to remove the .values() in qs = Doctors_list.objects.filter(id__in=unique.values()) leaving it like this:

qs = Doctors_list.objects.filter(id__in=unique)

What’s going on here is that with brackets in the first approach you’re creating a dictionary with just one key and a list as a the value of that key. When you issue .values() you get a list with the dictionary’s values. So it’s pointless to use a dictionary.

With the second approach you get a list directly.

Hope it helps.

Leave a comment