How do I calculate the average difference between two dates in Django?
问题 Using Django and Python 3.7. I'm tryhing to write a query to give me the average of the difference between two dates. I have two fields in my model, both "DateTimeField"s, and I try to calculate the average difference like so everything_avg = Article.objects.aggregate( avg_score=Avg(F('removed_date') - F('created_on'), output_field=models.DateTimeField()) ).filter(removed_date__isnull=False) return everything_avg but I end up getting this error when running the above AttributeError: 'dict'