[Answer]-Django: Date comparison and definition

1👍

The problem is here:

books = Borrowing.objects.filter(dueDate < today_date)

You’re doing filtering wrong. filter parameters should be field lookups, not just comparisons or even lambda functions. It should be

books = Borrowing.objects.filter(dueDate__lt=today_date) 

Refer to field lookups documentation for details why and how it works, and what are other options.

👤J0HN

Leave a comment