I'm very new to python and django and I'm working on a version of the locallibrary project to learn some concepts. I've created a model with an @property to show when an item is overdue:
@property
def overdue(self):
is_overdue = False
if (datetime.date.today() > self.due_date) and self.status != 'c':
is_overdue = True
return is_overdue
I would like to get a count of all items where overdue=True. In templates I can use 'overdue' as if it were a field, however, trying to use is in a view like this...
num_actions_overdue = Action.objects.filter(overdue='True').count()
...throws an error:
Cannot resolve keyword 'overdue' into field.
Is there a simple way to count all overdue records?
Thanks in advance for any help!