Filter by date yields empty queryset
Django version 4.2.x
The user picks a date, and I am trying to compare that to entries in the TeacherAvailability model.
The model:
class TeacherAvailability(models.Model):
teacher = models.ForeignKey(TeacherProfile, on_delete=models.CASCADE)
student = models.ForeignKey(
StudentProfile, on_delete=models.CASCADE, default=None, blank=True, null=True)
timeslot_start = models.DateTimeField(auto_now_add=False)
with the function:
def get_dayagenda(self, selectedDate):
year = int(selectedDate[:4])
month = int(selectedDate[5:7])
day = int(selectedDate[8:10])
And I have tried to return both of the following:
TeacherAvailability.objects.filter(student_id=None).filter(timeslot_start__year=year,
timeslot_start__month=month, timeslot_start__day=day).values_list('id', 'timeslot_start', 'student_id', 'teacher_id')
and
TeacherAvailability.objects.filter(student_id=None).filter(timeslot_start__date=datetime.date(year, month, day))
Both are yielding an empty queryset, however if I try just to filter by year I get some results.