Search_field for a definition in Django
In models.py
class PurchaseOrder(models.Model):
product = models.ManyToManyField('Product', null =True)
total_price= models.FloatField()
def get_total_price(self):
return sum([p.price_for_each_item for p in self.product.all()])
in admin.py:
search_fields = ['total_price'] will work. however, I can not search for
get_total_price. So how can I make it so that search can pick up
definitions. Or how can I make it so that the object total_price gets and
saves the value of the return on get_total_price?
No comments:
Post a Comment