When filtering a queryset with a ValuesListQuerySet instance in Django 1.6, different objects to that shown in the apparent list seem to be returned by the iterator.
An illustration of a head-scratching debug session is shown below:
(Pdb) latest[4, 1](Pdb) keys.filter(pk__in=latest).values_list('pk')[(3,), (1),)](Pdb) keys.filter(pk__in=[4, 1]).values_list('pk')[(4,), (1),)]
Can anyone explain this behaviour to me? When I fully convert it with list(latest), normal service resumes.
I have a suspicion that it's because of the Postgres-aware order_by() and distinct() chain, in the queryset that latest was produced from.
Thanks,
Marc.