How can I add a field for the count of objects in a database. I have the following models:
class Item(models.Model):
name = models.CharField()
class Con
Another way of doing this would be using Aggregation. You should be able to achieve a similar result using a single query. Such as this:
Item.objects.values("contest").annotate(Count("id"))
I did not test this specific query, but this should output a count of the items for each value in contests as a dictionary.