This is a very stupid thing, I know, but I just don’t seem to get the handle on Django aggregate and annotate functions.
I have a very simple set of models: Events, Areas and Types. An event has foreign keys pointing to Area and Type. I would simply like to have the number of forthcoming events for any area and the same for any type, i.e. Area1 – 5 forthcoming events, Area2 – 6, or Type1 – 34 events and so on.
I would like to avoid writing custom SQL, and the q operator if possible.
for a given area:
annotation
or
See the following docs:
https://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate