0

I would like to build versioning for my django models. I have already tried django-reversion but i think that is not good for my use case and i have problems with many-to-many through models and multi table inheritance.

My use case: I have a multi tenant web app. Every tenant have their own pool of resources. The tenants can create documents and reference to the resources. Here is a simple diagram: enter image description here

Now on every update from the document or a resource that is referenced in the document i would create a version of the document. So the version should show all changes of the document and the referenced resources. But on revert to a version only the direct values of the document should reverted and not the resources. For example a document: enter image description here

Now i edit the document and delete the resource_1 with the id 1. Also i change the name from the resource_1 with the id 2. enter image description here

When i revert this document to the first version, it should look like this: enter image description here

But how can i achieve this? I think i can use MongoDB to store complete version of a document as serialized json data on every update. And can create a signal for the resources if it changed and check the correspondent documents to create also a version for the document. Then i create for each tenant a new collection in MongoDB.

The resources itself should also have a versioning and also other models in my webapp but for the example that is not important.

Basti G.
  • 411
  • 1
  • 5
  • 26

0 Answers0