Login

All snippets written in Python

Snippet List

Fetching top items

This is a method from the custom manager for the Snippet model used on this site; the basic idea is to be able to ask for the top `n` "foo", where "foo" is something related to Snippet. For example, you can use `top_items('tag')` to get the top Tags ordered by how many Snippets are associated with them. I have a feeling that I could get this down to one query, but haven't yet put in the time for it.

  • snippets
  • sql
  • managers
  • group-by
Read More

2956 snippets posted so far.