After calculating field in model I want to display this field in my template
model:
def _get_total(self):
from inventory.models import Inventory
from purchase.models import POproduct
from sales.models import SOproduct
# "Retus the total"
retu Inventory.objects.filter(warehouse_Bin__material_UOM__UOM__material=self.id ).aggregate(Sum('quantity'))
#- SOproduct.objects.filter(product__material=self.id).aggregate(Sum('quantity'))
#POproduct.objects.filter(Product__material=self.id).aggregate(Sum('quantity'))
total = property(_get_total)
template:
<div> <b>total on hand:</b> {{ data.material.total }}</div>
However template displayed value in this format instead of plain numeric value
total on hand: {'quantity__sum': Decimal('97.00000')}
I was trying to add parameter , output_field = models.DecimalField() to my sum function but getting an error I do not understand
'DecimalField' object has no attribute 'resolve_expression
'
