Here, as I just discovered, is how to do this with the Django 1.1 aggregation API:
from django.db.models import Count
theanswer = Item.objects.values('category').annotate(Count('category'))
More Related Contents:
- Django -> queryset[index] Index out of range
- Check if a dictionary contain data true of false, then send a response back
- django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. plz help me out plz
- How to set environment variables in PyCharm?
- How do I access the request object or any other variable in a form’s clean() method?
- MySQL “incorrect string value” error when save unicode string in Django
- Should I be adding the Django migration files in the .gitignore file?
- Loading initial data with Django 1.7 and data migrations
- Django: “projects” vs “apps”
- Django : Table doesn’t exist
- Error loading MySQLdb Module ‘Did you install mysqlclient or MySQL-python?’
- django – convert a list back to a queryset [duplicate]
- How to set up custom middleware in Django
- How to write setup.py to include a Git repository as a dependency
- How do I separate my models out in django?
- How can I check if a Python unicode string contains non-Western letters?
- When should I use escape and safe in Django’s template system?
- How to execute arithmetic operations between Model fields in django
- gunicorn autoreload on source change
- Order of Serializer Validation in Django REST Framework
- django apache configuration with WSGIDaemonProcess not working
- How to perform OR condition in django queryset?
- Override a form in Django admin
- Django equivalent of PHP’s form value array/associative array
- How to get python-dev for windows?
- Resize fields in Django Admin
- Rendering JSON objects using a Django template after an Ajax call
- “gettext()” vs “gettext_lazy()” in Django
- How to properly use the “choices” field option in Django
- “Failed building wheel for psycopg2” – MacOSX using virtualenv and pip