Reputation: 25547
I have various models of which I would like to keep track and collect statistical data.
The problem is how to store the changes throughout time.
I thought of various alternative:
What are your suggestions?
Upvotes: 6
Views: 1790
Reputation: 6005
I've had similar situation in which we were supposed to keep the history of changed. But we also needed audit to track who made the changes and the ability to revert. In our approach storing in database seemed more logical. However considering you have statistical data and it's gonnna be large, perhaps separate file based approach would be better for you.
In any case you should use a generic mechanism to log the changes on models rather than coding each model invidually.
Take a look at this: http://www.djangosnippets.org/snippets/1052/
Upvotes: 1
Reputation: 43487
Quoth my elementary chemistry teacher: "If you don't write it down, it didn't happen", therefore save logs in a file.
Since the log information is disjoint from your application data (it's meta-data, actually), keep them separate. You could log to a database table but it should be distinct from your model.
Text pickle data is difficult for humans to read, binary pickle data even more so; log in an easily parsed format and the data can be imported into analysis software easily.
Upvotes: 1
Reputation: 239810
Don't reinvent the wheel.. Use django-reversion for logging changes.
I'd break statistics off into a separate model though.
Upvotes: 6