Hi folks, some of you may remember I'm working on a site for birders where they can enter and keep track of their observations of various birds.
Multiple viewings of a species can be entered at different observation locations, so for the ranking page (which considers only the number of distinct species), I need to find the set of observed species with multiple viewing dropped from the set. I've tried something like this: birds_observed = {} for o in observations: birds_observed[o.bird.id] = 1 number_of observations = len(birds_observed) and then repeat that loop for every observer in the database. Using the excellent debug snippet from djangosnippets.org, I've found this creates about 3,000 sql queries total on the database of the form select bird_id from club300_birds where ..... for each and every observation in the above set, rinse and repeat for every observer being ranked. My question: Is it possible to have Django select the distinct() bird_ids from a set of observations for a given observer? I've tried using raw SQL queries, but it feels and looks like a hack and a definite break of the DRY principle, and usage of the django distinct() query function sadly eludes me. Thanks in advance for your comments, Uwe -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.