if self._midnight(today) returns a datetime object, than:
self.filter(end__gt=self._midnight(today))
will evaluate to: self.filter(end__gt=<some_datetime_object>)
While self.filter(Field.end > self._midnight(today))
will evaluate to: self.filter(<True/False>)No it won't, because there's no requirement that the result of `>` be True or False. It can return an object that then can participate in further expressions that "keep track" of what operations are done to the fields.
Not if you do the magic with getattr and comparison overrides. You actually need to do it on the metaclass because the Field as I wrote it isn't an instance but this works:
This gives: You can make python return arbitrary values for comparisons by overriding __gt__ (and lt, eq) on the first operand (which we control here since it is a Field class), it doesn't have to be a bool.Edit:
You can even make a little adapter to use this with the current filter system if you really want to:
This printsend__gt = 2024-01-01 00:00:00