February 2018
Intermediate to advanced
456 pages
9h 56m
English
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 PriceList, in 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, ...
Read now
Unlock full access