To be more specific it looks like this:
((pow(2*math.pi*v,2)))*((pow(2,2))
piece of your very large single line of calculation is the culprit.
You should be able to convert to a decimal like so:
{previous_stuff_here} * Decimal(str(((pow(2*math.pi*v,
2)))*((pow(2,2)))) * {more_stuff_here }
As a readability thing, you might want to split that giant line of
code into a few separate calculations, but that's just an idea!
Cheers,
Dan Harris
dih...@gmail.com
On Jun 10, 3:33 pm, Dan Harris <
dih0...@gmail.com> wrote:
> The error looks like you are attempting to multiply a decimal by a
> float which isn't allowed. Django coerces form fields like
> DecimalField into a decimal object. See:
http://docs.python.org/library/decimal.html
> for more information about the decimal object.
>
> An error occurs like the one you have if you do something like:
>
> >>> from decimal import Decimal
> >>> import math
> >>> d = Decimal("2")
> >>> d*math.pi
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for *: 'Decimal' and 'float'
>
> You can convert the decimal returned by the form into a float, or
> convert the floats into decimals and do your math. Converting to
> decimal is probably more precise.
>
> Hope this helps,
>
> Dan Harris
>
dih0...@gmail.com