I have a model with a field, and I wanted to pull all the unique
values of that field.  So I do this:

    distinct_values = Model.objects.values('some_column').distinct()
    print 'distinct_values.count()', distinct_values.count()
    print 'len(distinct_values)', len(distinct_values)

Which gives:

    distinct_values.count()    4
    len(distinct_values)       137

This seems wrong.  If I do this:

    print distinct_values

or

    for value in distinct_values:
        print value

I get the entire list of values from every row in the database.  It
does not print only the distinct values, as I'd assume it would.

The closest I've found is this closed ticket from a year ago:
http://code.djangoproject.com/ticket/2939
But that is ticket is different: 1) it shows the correct results when
printing the results, and the len() and count() results are swapped
from this example.

Is anyone else seeing this?  Maybe I just have my code mixed up.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to