On Mon, 2008-03-03 at 02:30 -0800, Matt Hoskins wrote: > In my application I have a component for displaying paged sorted > tables of objects. Sometimes it's relevant for a column to show > information from a related object. In some cases it's relevant for the > column to show information from related objects where the related > objects are related via a many to many. That's easy enough to do. It's > desirable to be able to sort on such columns. When not sorting on that > column the column will show the names of all the related objects for > the given row. When sorting on that column it's desirable to show the > name of the related object that sorts to that position. > > So if you have Contract A and Contract B with Contract A linking to > Supplier 2 and Contract B linking to Supplier 1 and Supplier 3 the > desired results to display (when sorting by supplier) would be: > Contract B | Supplier 1 > Contract A | Supplier 2 > Contract B | Supplier 3 > > (when sorting on contract name you'd just see one row for Contract B
Having read this again in light of your complaint in #6701, I should point out that it's not going to work like this if you're always filtering on Contract. A queryset is going to return one object for each distinct object if you do the equivalent of Contract.objects.all(), not on per many-to-many result. So if you want to order by suppliers like this, you'll need to do a queryset based on suppliers and pull back their related contract objects and then you can order on suppliers however you like. Malcolm -- I just got lost in thought. It was unfamiliar territory. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---