I have a model Chairwith a text box color. I want to get a dict in the following format:
{'red': 53,
'green': 1582,
'cyan': 73}
Each number is the number of rows of a chair with this color, counting all the chairs in the database.
How can I do this using Django ORM? (My database is Postgres, if that matters.)
source
share