Do this:
def __gt__(self, value):
return Q(**{ f"{self.name}__gt": value })
and your original code should work as-is without the need for _() self.filter(Field.end > self._midnight(today))
https://docs.djangoproject.com/en/6.0/topics/db/queries/#com...