-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to sort via related objects? #7
Comments
I ran into this myself, and found that you can do this by using django's double-underscore syntax, so above you would want to use "blog__type". Hope this helps, 8 months later ;) |
It definitely helps -- many thanks! Weirdly enough, i've been working on another part of my app and was now about to rewrite the sorting code because of this apparent shortcoming. So thanks a ton for the solution -- it's never late! :) |
Excellent! Glad you were tracking the bug and able to use this! Totally makes my day. |
Added a foreign key to the example in the wiki so that others can find this as well. |
So far I couldn't find a way to sort through a related object's field.
Quick and dirty example:
And i have a table for Entries with three headers: Entry name, Blog name and Blog type.
I can sort the table by Entry name and Blog name, but not by Blog type. If i try
It comes up with a TemplateSyntaxError:
Caught an exception while rendering: missing FROM-clause entry for table "blog"
LINE 1: ...ND NOT ("testapp_entry"."id" IN (110))) ORDER BY "blog...
I'm wondering if there's a bug in here or if it's simply not implemented. A
pointer of what code to check would be great, i could try and fix/add it
myself. I'm betting that this can be accomplished by tweaking
templatetags/sorting_tags.py
, but i can't discern how it could be done.By the way, awesome extension! It was such a pleasure doing away with my hardcoded sorting code :-)
The text was updated successfully, but these errors were encountered: