views:

70

answers:

1

Hi,

I have an Invoice model with a boolean field: is_overdue . This field is set to True if the user did not receive a payment and the due_date is before the date of today.

Now I want to accomplish that this field is regularly updated. Ok one possibility is to update the field when the save method is called.

But how can I ensure that if the object is "called" (presented at the portal), that the is_overdue field is set correctly. Since I can not force the user to save the object before viewing the object ;-)

It would be great if it would be possible to overwrite the get object method and set the field there accordingly. With "get object method" I mean the call Invoice.objects.all() or similar..

+1  A: 

Make is_overdue a property that checks if the payment has been made and returns the appropriate value.

Ignacio Vazquez-Abrams
Thanks. I'm new to python / django and did not know the property concept. Here is some good information how to deal with properties: http://www.b-list.org/weblog/2006/aug/18/django-tips-using-properties-models-and-managers/ and here for django: http://www.djangoproject.com/documentation/models/properties/
Tom Tom