The second part of the patch cannot be correct, since datetime objects don't have a method called get() that operates like a queryset. Looks like you probably also want to change aggregate() to annotate() there, since the latter has a different return type (a queryset).