2๐
โ
So, you want to make objects with certain tags to display in the top?
There is similar problem. The idea is to add in select new field, which will hold boolean value, so you can sort by it.
You should add this field using django extra
queryset method.
MyModel.objects.extra(
select={
'tags_occurance': "(tags LIKE '%tag1%') + (tags LIKE '%tag2%')"
},
).order_by('-tags_occurance')
Should be something like this.
๐คdt0xff
Source:stackexchange.com