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

Now with queryset_refactor I can order by the supplier names no
trouble, and I get the correct ordering of contracts in the queryset,
but I don't think there's a clean way for me to get at the values from
the order_by when using a queryset returning objects without using
extras() to do the order_by and include it as a select extra (or use
extras() to just specify the select using the sql table name under the
assumption that it will be added in to fulfill the order_by).

Possible extra features in QuerySet that could provide me with a
tidier way of getting at it would be to allow the "select" part of
extras to specify supplier__name style references as well as just raw
SQL, or to just allow the "select" part of extras to specify a
supplier__name reference if it's in the order_by too then you get that
order_by back. An alternative is some way of saying "I want you to add
an attribute called order_bys to the objects in the returned set which
contain the order_by values". So then on each object from the queryset
I'd have .order_bys which would be, say, {'suppliers_name':'Supplier
1'}


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