[Answer]-How to return field ncm for other model?

1👍

Template access

From the product:

{{ some_product.ncm }}

From the SaleDetail:

{{ some_sale_detail.product.ncm }}

Python access

From the product:

class Product(models.Model):
    def get_ncm(self):
        return self.ncm

From the SaleDetail:

class SaleDetail(models.Model):
    def get_ncm(self):
        return self.product.ncm
👤Wolph

Leave a comment