I have a
Model Car(self.Models)
# a bunch of features here
then in my views.py, I get all the cars and compute a score for them:
allCars = Car.object.all() # so you get [A, B, C, D]
scoreList = someComputation(allCars) # returns [3,1,2,4]
then in my template I iterate through allCars to display them; using the ordering the query returned with I get primary key ordering, so
- A
- B
- C
- D
However I would like to know if there is a way to order the queryset using the list I computed in the view, which would yield
- B
- C
- A
- D
so doing something like
allCars.order_by(scoreList)