Creating the price list data model

Another feature that we want to have in our application is the ability to change the prices of the products as well as knowing when a price was added and, most importantly, when it was last updated. To achieve this, we are going to create another model class, called PriceListin the models.py file in the gamestore/main/ directory, using the following code:

class PriceList(models.Model):    added_at = models.DateTimeField(auto_now_add=True)    last_updated = models.DateTimeField(auto_now=True)    price_per_unit = models.DecimalField(max_digits=9,                                         decimal_places=2,                                          default=0)    game = models.OneToOneField(        Game,        on_delete=models.CASCADE,        primary_key=True)    def __str__(self):        return self.game.name

As you can see here, ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.