First things first: I would either define a separate Group object
here, or use a many2manyfield if you don't need to know the group
numbers.

Second thing: why use the assembly object if you want to count items ?
You are thinking to much in SQL instead of ORM.
If you say Assembly.objects.count(), I would think you want to count
assembly objects, which should yield 2 no matter what extra stuff you
pull in using select_related(). For the ORM side of things,
select_related just prepopulates some related data, no more, no less
(which is of no use in combination with count).
In that view, it would be better if the filter would automatically use
distinct here and also return 2, since you are still only counting
assembly objects. If you do the same using a many2manyfield, the
result is correct as far as I can tell.
If you want to count items, I would use
Item.objects.filter(whatever_filter).count().

Koen





--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to