My models:
Item:
name
desc
Type:
name
Value:
item.ForeignKey(Item)
type.ForeignKey(Type)
val.CharField # varchar or numeric
Now I have an objects list of items but not a QuerySet, for instance: items = [<object:1>, <object:2>, <object:4>]. And t = 5 is an id of a row from Type.
I want to sort this list by val of table Value and type of value is t. Any idea?
Thanks alot!
UPDATE:
– I’ve added a new condition.
You can always use lambda function to sort the list of items (assuming there is a one to one relationship between
ItemandValuemodel, otherwise I don’t think the question makes sense)Although the point to be noted is that the sorting will be in memory.
For Updated Question
Just adding a filter should do the task