views:

34

answers:

1

I have a Django model for Cat which has a foreign key Dog. The Dog model has a date key timestamp. I want to order the cats, using Cat.objects.order_by, according to the timestamps of their respective dogs. How do I do that?

+2  A: 

Use the double-underscore syntax.

Cat.objects.order_by('dog__timestamp')
Daniel Roseman