How to Implement Model Versioning in Django Without Affecting Transactional Data

MODELS

Transaction Model

class TransactionOrders(models.Model):
    product = models.ForeignKey(Product, on_delete=models.DO_NOTHING)
    customer = models.ForeignKey(Customer, on_delete=models.DO_NOTHING)
    ...

class Product(models.Model):
    name = models.CharField(max_length=55, unique=True)
    title = models.TextField()
    ...

class Customer(models.Model):
    customer_id = models.CharField(max_length=55,  primary_key=True)
    name = models.CharField(max_length=100)

# there might be more models

Imagine we have some entries in transaction model now admin updated or soft deleted some entries in product | customer models

issue: Old data modified either with new value or showing ids (whose entries are updated | deleted respectively)

Requirement: How can I avoid so above issue so that when user creating new order updated value reflected & when user visit history order then it show's entries which has values at that time

Note: If I haven't able to clarify let me know I try to put more data to make my query understandable

Back to Top