How to deal with date change in a django query

Viewed 21

I have a model of a kind of todo list that, amongst others, contains fields for the weekday and the time the task has to be completed.

Let's say I have a night shift. Some tasks have to be performed before midnight, others after. Now I want to list tasks that, for example, have to be completed on a Friday in the todo list of the shift starting Thursday.

One possibility is to reflect that on the model side, i.e., to enter tasks that should be finished Mon-Fri morning with weekdays Sun-Thu. Then the query is rather straightforward, but one has to be careful when entering new tasks. Is there also a way to enter the "correct" weekdays and deal with the date change on the query side? I saw approaches with union and itertools.chain, but then I'm limited in further operations on the queryset (like another filter or annotate).

Is there another way?

0 Answers
Related