I have this queryset in Django:
obj = Obj.objects.annotate(duration = F('date_end') - F('date_start')).order_by('duration')
The following works perfectly:
obj[0].duration
obj.aggregate(Sum('duration'))['duration__sum']
However filtering doesn't work in this case even though documentation says that it should:
obj = obj.filter( duration__gte = <a_class_datetime.timedelta> ) # doesn't work
obj = obj.filter( duration = 1 ) # doesn't work
This is the error I am getting:
TypeError: expected string or bytes-like object
My way to bypass this issue is to loop through the dataset - which is huge. Any tips as to why this is not working?