Hi, I'm not sure to understand what I'm doing here :) I have a model of a photo with name, description, image field... and a generic foreign key called 'likes' to store the photo in users' favorites:
likes = generic.GenericRelation(Like)
and in the Like model I have:
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
Now when I want to display a user's favorites I can do:
q = Q(likes__user=user)
favorites = Photo.objects.filter(q)
it works ok but the result is ordered by Photo pk so if a user likes a photo that has been uploaded a long time ago it appears very far away in the favorites list. I would like to order that list by the pk of the Like object but I have no idea how to do that.
I don't know if I made myself clear. Any help is welcome.
Cheers,
Bastian