1👍
It’d be handy if you posted your model.py
, but I’m going to make some guesses.
Firstly, this might help:
#views.py
def questions(request, movie_id):
p = Movie.objects.get(pk=movie_id)
k = Question.objects.filter(movie=p).order_by('-q_pub_date')
...
(don’t need to use reverse, can just begin it with -
)
I’m going to guess that your score could be sorted as follows:
k = Question.objects.filter(movie=p).order_by('movie__score', '-q_pub_date')
The __
(double underscore) will refer to an attribute of related model.
I’ve been known to live and die by this: https://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects
Source:stackexchange.com