Reputation: 776
Will try to make a general example: I have a "Material" model with a Foreign key to a "Price". During the year 2020, a "Material" has one price, but in the year 2021 I want to change the "Price" but still keep track of the history of price changes.
The summed cost of a "Material" consumption during 2020 should not change because of a "Price" change during 2021.
Is there a common strategy to handle this in Python/Django?
Upvotes: 0
Views: 59
Reputation: 2334
Make the Price as a model which is something as follows
class Prices(models.Model):
material = models.ForeignKey(Material,...)
year = models.IntegerField()
prices = models.DoubleField()
Then you can get the price of a material in a certain year.
Upvotes: 2