I have the following model in django:
action = models.CharField("Action performed",max_length=200,db_index=True)
date = models.DateField("Date when event occured",blank=True)
time = models.TimeField("Time when event occured",blank=True)
timestamp = models.DateTimeField("Timestamp when event occured",blank=True,null=True,db_index=True)
username = models.ForeignKey(USER)
computer = models.ForeignKey(COMPUTER)
location = models.ForeignKey(LOCATION)
I wish to return data to a HTML page, which has the following columns:
COMPUTER NAME, COUNT(LOGON), COUNT(LOGOFF)
I am using
logOnOffData = LOGONOFF.objects.all()
computerBreakDown = logOnOffData.values("computer__computerName").annotate(Count("timestamp"))
This generates the number of occurrences of each computer being included in the database table. I can easily generate a queryset for each action, but cannot see how to include the results of the two querysets into one.