Annotate a queryset with the average date difference? (django)
问题 I searched all over place for an answer to this but couldn't find anything. Perhaps this is just a stupid question or a really tricky one. Here it is: Let's say my model is this (pseudo django code): Event type = ForeignKey(EventType) name = CharField date_start = DateField date_end = DateField EventType name = CharField What I want to know is the average duration time for each event type. What I do now is calculate the average duration whenever a new event is created (save method) and have