On Mon, Feb 2, 2009 at 11:59 PM, Martin Conte Mac Donell <refl...@gmail.com> wrote: > If you need country_id/country_name: > >>>> Profile.objects.values('country__id', >>>> 'country__name').select_related('country').distinct() > [{'country__name': u'Country1', 'country__id': 1}, {'country__name': > u'Country3', 'country__id': 3}] > > Which run this query: > >>>> Profile.objects.values('country__id', >>>> 'country__name').select_related('country').distinct().query.as_sql() > ('SELECT DISTINCT "b_profile"."country_id", "b_country"."name" FROM > "b_profile" INNER JOIN "b_country" ON ("b_profile"."country_id" = > "b_country"."id")', ())
Also you can ommit select_related('country') which is implicit with "country__name" and "country__id". M. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---