I'm creating a CRUD application that displays activities available on or after today; I'm working through the filtering mechanism on displaying these activities, however I'm having a nightmare trying to only show the activities that are on/after today.
I'm getting the below error when I try to use the '>=' operand, however it's giving me the following error:
'>' not supported between instances of 'type' and 'datetime.date'
Below is my views.py for the comparison:
today= date.today()
available_activities = Activity.objects.filter(available = True).values()
activities = available_activities.filter(date > today).values()
activities= available_activities.order_by('date','start_time')
Below is a screenshot of the error traceback also, to show the data format for the data in the DB also.
CodePudding user response:
You filter with the __gt
lookup [Django-doc]:
today = date.today()
available_activities = Activity.objects.filter(
available=True, date__gt=today
).order_by('date', 'start_time')