Keep history in django to draw graphs
I am looking for the best way to have an history of my models (interger & float fields) in Django. I read 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 ?
T开发者_JS百科IA.
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.
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.
精彩评论