Lets say if I have a model that has lots of fields, but I only care about a charfield. Lets say that charfield can be anything so I don\'t know the possible values, but I kn
You want something similar to "count ... group by". You can do this with the aggregation features of django's ORM:
from django.db.models import Count
fieldname = 'myCharField'
MyModel.objects.values(fieldname)
.order_by(fieldname)
.annotate(the_count=Count(fieldname))
Previous questions on this subject: