1

I want to annotate a datetime field to a queryset using timedelta and F objects

Example:

Model.objects.annotate(end_time=F('start_time')+timedelta(minutes=F('meeting_duration')))

Here I have a field "start_time" and "meeting_duration" in my table and I want to calculate and annotate an end_time using datetime.timedelta

And thereafter filter the queryset using the annotated field.

queryset.filter(end_time__gte=self.end_time)

Now I get this error:

TypeError: unsupported type for timedelta minutes component: F

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mohit Harshan
  • 1,916
  • 1
  • 18
  • 41

0 Answers0