Alright, let's see if I can explain this:

I have an Artist model and artists get positionally ranked. It has a
GenericRelation to another model that stores scores from that ranking.
I wanted to be able to sort Artists by their score using that
GenericRelation. Here's an example (ran this in the interpreter) of a
list of artists ranked by a specific user.

>>> items
[<Artist: Kamei Eri>, <Artist: Li Chun>, <Artist: Michishige Sayumi>,
<Artist: Mitsui Aika>, <Artist: Murata Megumi>, <Artist: Niigaki
Risa>, <Artist: Okada Yui>, <Artist: Qian Lin>, <Artist: Satoda Mai>,
<Artist: Shimizu Saki>, <Artist: Sudou Maasa>, <Artist: Takahashi Ai>,
<Artist: Tanaka Reina>, <Artist: Tokunaga Chinami>, <Artist: Tsugunaga
Momoko>]
>>> items.order_by('overall_child__score')
[<Artist: Li Chun>, <Artist: Takahashi Ai>, <Artist: Niigaki Risa>,
<Artist: Kamei Eri>, <Artist: Michishige Sayumi>, <Artist: Tanaka
Reina>, <Artist: Okada Yui>, <Artist: Murata Megumi>, <Artist: Mitsui
Aika>, <Artist: Qian Lin>, <Artist: Shimizu Saki>, <Artist: Tsugunaga
Momoko>, <Artist: Tokunaga Chinami>, <Artist: Sudou Maasa>, <Artist:
Satoda Mai>, <Artist: Okada Yui>, <Artist: Murata Megumi>]
>>> items.order_by('overall_child__score').distinct()
[<Artist: Li Chun>, <Artist: Takahashi Ai>, <Artist: Niigaki Risa>,
<Artist: Kamei Eri>, <Artist: Michishige Sayumi>, <Artist: Tanaka
Reina>, <Artist: Okada Yui>, <Artist: Mitsui Aika>, <Artist: Murata
Megumi>, <Artist: Qian Lin>, <Artist: Shimizu Saki>, <Artist:
Tsugunaga Momoko>, <Artist: Tokunaga Chinami>, <Artist: Sudou Maasa>,
<Artist: Satoda Mai>, <Artist: Okada Yui>, <Artist: Murata Megumi>]
>>> items.count()
15
>>> items.order_by('overall_child__score').count()
15

As you can see, <Artist: Okada Yui> and <Artist: Murata Megumi> are
duplicated, but the .count() doesn't reflect that. Here's the kicker,
in the table that the GenericRelation is linked to, those two records
occur twice. I had some friends test my application last night the
number of duplicates was equal to the number of people that included
that specific artist in their ranking.

It's an OUTER JOIN, but I don't know if that has anything to do with
it, but it seems to ignore any type of filtering that I'm trying to do
to it. Hopefully that makes some kind of sense. I don't know if
there's a way around it, or if it's a bug that needs to be fixed. But
any insight would be great. :)

Cheers,
Bryan

-- 
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.

Reply via email to