Answer the question
In order to leave comments, you need to log in
How to solve a problem in python3, Django?
There is a model file https://gist.github.com/octoberweb/87700041bb16439... containing the Event model. The event can take place either on the same day when there is date and no date_end, or in the period, for example, from 06/14/17 to 06/18/17, then date_end is the end date of the event.
It is necessary to make it so that it would be possible with the help of the commands:
Event.objects.current() to get the current events for today's date.
Event.objects.archive() get all past events.
Answer the question
In order to leave comments, you need to log in
Offhand, all the past something like this:
now = datetime.date.today()
q = Q(date_end__isnull=False)&Q(date_end__lte=now)
q |= Q(date_end__isnull=True)&Q(date__lte=now)
qs = Event.objects.filter(q).distinct()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question