python - Get number of occurrences of certain attribute in a related table in an aggregation in django -
i'm creating extensible analytics app django, idea have table events wish track , table connects events, date , user.
here main model:
class events_tracked(models.model): data_point = models.foreignkey('data_points', related_name='data_point') event_date = models.datetimefield(default=datetime.datetime.now()) user = models.foreignkey('users', related_name= 'user_tracked')
my problem create django query can group events tracked month, , return number of tracked events (rows) data_point__id id specify.
preety sure do:
events_tracked.objects.values('event_date__month').annotate(count('data_point')).filter(data_point__id=1)
but limited count of single data point, need query can return count row each of data points want track.
edit: important query need build each month, number of users had events tracked, data_point id in list of id's.
Comments
Post a Comment