sorting a List of related foreign-key records? #654
Unanswered
davidroberthoare
asked this question in
Q&A
Replies: 1 comment
-
|
Hello. For models, you can specify a default sort: # app/models.py
class Part(models.Model):
...
class Meta:
ordering = ('start_time',) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My Schema are like this:
And I can successfully now list all events, with their associated parts and tags, etc...
However, the related lists ('parts' and 'tags') are not ordered. For example, I would like to order the parts list for each event by the "part.start_time" field. But if I include
order_by="parts__start_timeit just duplicates the Event row in the result (and doesn't sort the parts either)...How can I accesss/sort the foreign-key-related lists that are being returned so nicely in this schema? :)
Thanks!
David
Beta Was this translation helpful? Give feedback.
All reactions