From the course: Securing Django Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Deleting objects in an audit/compliance-compatible way

Deleting objects in an audit/compliance-compatible way - Django Tutorial

From the course: Securing Django Applications

Start my 1-month free trial

Deleting objects in an audit/compliance-compatible way

- [Instructor] When deleting data in a Django app we need to be aware of compliance requirements and whether the data can be truly deleted. We create a new data model, which will store a copy of the deleted data. So we need to store the model type that was deleted. And then we have to store the ID of the model that was deleted. And then we store the actual data. And now whenever we delete a booking model instance, we're going to be archiving it, and storing it in the DeletedData model. Now we do this by using DJango serializers and we're going to store a JSON copy of this instance that was deleted, and then we're going to store it in the DeletedData objects. So the model type is booking. The model ID is the instance ID, and the data is the serialized version of that data. Later on, if we ever need to recover this data, and restore it, we can do that just given the ID. We can find it in deleted data. Say that the…

Contents