Quiero mostrar lo que me devuelve la función get_price.
Dejo el código del models.
class OrderItem(models.Model):
product = models.OneToOneField(Product, on_delete=models.CASCADE, null=True)
quantity = models.IntegerField(default=1)
def __str__(self):
return self.product.name
def get_price(self):
return self.product.price
Dejo el models de product, ya que no funciona al poner {{ object.get_price }}
class Product(models.Model):
name = models.CharField(max_length=255)
price = models.FloatField()
price_offer = models.FloatField(null=True, blank=True)
photo = models.ImageField(upload_to='products/photos')
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
get_price
sin problemas, todo esta bien...