tags:

views:

33

answers:

2

Hello,

I am looking for the best way to have an history of my models (interger & float fields) in Django. I read http://stackoverflow.com/questions/1952913/keeping-a-history-of-data-changes-in-database and it seems that triggers are the best option.

My idea is to stay database agnostic if possible.

How do you approach this issues in your django code ?

TIA.

A: 

If you're not going to go with Triggers, Signals do a similar job — it'll (probably) be less efficient than using a trigger, but you can attach a post_save signal to your models you want to track and do all the processing you need there.

obeattie
A: 

You should check out Django Reversion app. It's probably the easiest way to implement what you want in your project, especially if you'd also like to restore earlier versions of your model(s). If not, it might be a bit overkill.

Edit: You should also examine Django History. Might be more along the lines of what you really need. However it hasn't been updated in a long time, you might have to just use it as inspiration for your custom solution.

Béres Botond
I have been coding a simple django-history.But still I would be interested to see what the best pratice to keep data in a database for graph purposes.
Thomas
Well it's hard to say, depending what models do you have and what kind of graphs you want to generate from them etc. But one common/basic practice to optimize functionalities that deal with 'SELECT'-ing a lot of data is *denormalization* of some models.
Béres Botond