So, I'm trying to calculate the coffee price of the parameters mentioned below. But, every time I try to call the coffeeprice method, it gives me a conversion from method to Decimal is not supported error.
I have the following code in my view and model respectively:
def order(request):
    if not request.user.is_authenticated:
        raise Http404()
    order_form = OrderForm(request.POST or None)
    if order_form.is_valid():
        obj = order_form.save(commit=False)
        obj.price = Decimal(obj.coffeeprice)
        obj.save()
        messages.success(request, "Thank you for your order.")
        return redirect("arabica:list")
    context = {
        "order_form": order_form,
    }
    return render(request, 'order.html', context)
class Coffee(models.Model):
    ONE = 1
    TWO = 2
    THREE = 3
    FOUR = 4
    FIVE = 5
    SHOTS_CHOICES = (
        (ONE, 'One'),
        (TWO, 'Two'),
        (THREE, 'Three'),
        (FOUR, 'Four'),
        (FIVE, 'Five'),
    )
    user = models.ForeignKey(User, default=1)
    name = models.CharField(max_length=50)
    bean_type = models.ForeignKey(CoffeeBean)
    roast_type = models.ForeignKey(Roast)
    shots_number = models.IntegerField(default=ONE, choices=SHOTS_CHOICES) 
    syrup_type = models.ManyToManyField(Syrup)
    powder_type = models.ManyToManyField(Powder)
    water = models.FloatField()
    milk = models.BooleanField(default=False)
    foam = models.FloatField()
    extra_instructions = models.TextField()
    price = models.DecimalField(max_digits=6, decimal_places=3)
    completed = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return self.name
    def coffeeprice(self):
        total = 0
        total += self.bean_type.price
        total += self.roast_type.price
        for syrup in self.syrup_type.all():
            total += syrup.price
        for powder in self.powder_type.all():
            total += powder.price   
        if self.milk:
            milk_price = .25
            total += milk_price
        shots_price = self.shots_number * .5
        total += shots_price
        return total
I tried importing and placing Decimal() at different stages and at different variables, with no luck.
Your help is greatly appreciated.
Thank you.
 
     
    