3
So, after looking into this long and hard, I think the best solution for me is to create a ‘flat’ version of the object, dereferencing any existing objects, and save that in the database.
The reason for this is that my ‘BoxOrder’ object can change every week (as the customer edits their address, item, cost etc. Keeping track of all these changes is just plain difficult.
Plus, I don’t need to do anything with the data other than display it to the sites users.
Basically what I am wanting to do is to create a snapshot, and none of the existing tools really are what I want. Having said that, others may have different priorities, so here’s a list of useful links:
[1] SO question regarding storing a snapshot/pickling model instances
[2] Django Simple History Docs – stores model state on every create/update/delete
[3] Django Reversion Docs – allows reverting a model instance
For discussion on [2] and [3], see the comments on Serafim’s answer
3
This is a rather broad topic, and I won’t specifically answer your question, however my advice to you is don’t delete or move anything. You can add a boolan field to your Item
named is_deleted
or is_active
or something similar and play with that flag when you delete your item. This way you can
- keep your
ForeignKey
s, - have a different representation for non-active items
- restore and
Item
that was previously deleted (for instance you may want to sell Carrots again after some months – this way your statistics will be consistent across the year)
The same advice is true for the BoxOrder
model. Do not remove rows to different tables, just add an is_archived
field and set it to True
.
- [Django]-Django and django oscar
- [Django]-`lookup_field` doesn't work on `ListAPIView`
- [Django]-Encode ImageField in base64 and store it in DB instead of path of the image