I have below model, which has all the details about customer Leads. Customer wants to see his Leads followup statuses.
class FollowUp(models.Model):
CALL_CHOICES = [("0", "Call Unanswered"),
("1", "Call Later"),
("2", "Visit Scheduled"),
("3", "Not Visited"),
("4", "Not reachable"),
("5", "Wrong Number"),
("6", "Not Interested"),
("7", "Deal Closed")]
status = models.CharField(_("Call Status"),
max_length = 20,
choices = CALL_CHOICES,
default = '1'
)
next_action_on = DateTimeField(_("Next Action"), auto_now_add=False,
null=True, blank=True)
reminder = models.BooleanField(_("reminder"), default=False)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Lead(models.Model):
followups = models.ManyToManyField(FollowUp, verbose_name=_("Follow up"), blank=True)
...
How can I get Lead counts of each status choice. such as
{
'Call Unanswered': 12 #Leads,
'Call Later': 10 # Leads
'Visit Scheduled': 20, #Leads,
...
}