Following up on my last post... After using distinct(), the count() is what I expect, but when I iterate through the queryset results there are more results that I expect, and the count of the queryset changes (see example below).
------------------------------------------ def get_unique_vehicles(): q = TruckLog.objects.values('vehicleid').distinct() print 'count before loop = ' + str(q.count()) for i in q: print i print 'count after loop = ' + str(q.count()) ------------------------------------------ Produces the following output... ------------------------------------------ count before loop = 3 {'vehicleid': 80533} {'vehicleid': 80480} {'vehicleid': 80437} {'vehicleid': 80437} {'vehicleid': 80533} {'vehicleid': 80480} {'vehicleid': 80533} {'vehicleid': 80533} {'vehicleid': 80437} {'vehicleid': 80533} {'vehicleid': 80480} count after loop = 11 ------------------------------------------ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---