In Django, I have a model, and I will have a dictionary having the id's of objects in this model as keys, and a weight as values. I would like to use these weights in an order_by:
MyModel.objects.filter(title__icontains=query).order_by( 'value_from_the_dictionary' )
How to make this work?
I can't put the weights in the model, as they will be different in each call of this view, and I don't want to save them anywhere, they will be calculated on each query of the URL.