1👍
✅
Actually, if, for example, the tags are applied to a model called Joke, you can simply do this:
tags = Joke.tags.most_common()
And it works just fine.
1👍
Assuming that the tags are stored in a list:
sorted(lst, key=lst.count, reverse=True)
collections.Counter
also works and has the advantage of being O(n)
counts = collections.Counter(lst)
new_list = sorted(lst, key=lambda x: -counts[x])
- [Answered ]-Django raise ValidationError
- [Answered ]-Using django subdomain and it says localhost does not belong to the domain example.com
- [Answered ]-Parent calling abstract method in python
Source:stackexchange.com