I am trying to filter the results of a django query according to a given end and start time. In my model I have a start time and duration for every database entry. I give the function the parameters endTime and startTime
What I would like is to have a filter that checks if the given endTime is smaller than the start time + duration given in the database row, so something like the following query:
query = Results.objects.filter(
r_timeStart__gte=startTime,
(F('r_timeStart') + F('r_duration'))__lte=endTime)
This obviously does not work. Now is my question: is it possible to compare a variable to two accumalated database fields in a django query?
Copyright Notice:Content Author:「cyrion1000」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32211294/is-it-posible-to-compare-a-variable-to-two-accumalated-database-fields-in-a-djan