tags:

views:

18

answers:

1

I have a Django application which edits a database table, which another application polls and uses to update a downstream system. In order to minimize processing when the database has not been altered in between polls, I would like to use a global modification time for a model, which is updated every time a row is created/deleted/modified. How can I do this within the Django ORM?

+2  A: 

Django does not give you access, nor does it maintain, a "last modified" date on a table (model). You need to implement this by yourself, but this isn't complicated.

The easiest way would be to catch the necessary signals in your model by implementing the post_save() and post_delete() model signals (hooks, basically), and maintaining a static date field which represents the "last modified" date you are looking for.

Yuval A
Thanks -- could you possibly expand on the concept of a "static field": is this a separate Model?
kdt
Well, you could do a separate model, but that's unnecessary. I would stick it in the models `Meta` class.
Yuval A