Wednesday, 15 September 2010

Django select distinct in mysql -



Django select distinct in mysql -

how next query in django:

asset.objects.all().distinct('checksum') # distinct checksum items

the equivalent in sql be:

select * asset grouping checksum

note need all fields here, cannot asset.objects.values_list('checksum').distinct(). how this?

do want first item of every checksum?

items = asset.objects.all() items.query.group_by = ['checksum'] print items [<asset: ...]

mysql django

No comments:

Post a Comment