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
[email protected]
On Jun 10, 3:33 pm, Dan Harris <[email protected]> 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
> [email protected]
>
> On Jun 10, 3:22 pm, Waleria <[email protected]> wrote:
>
>
>
> > Hello..
>
> > I again.....now my problem is:
>
> > I have the function following:http://paste.pocoo.org/show/224041/
>
> > These values i get of a form...however returns me an error....fallows
> > below the error
>
> > Exception Type: TypeError
> > Exception Value: unsupported operand type(s) for *: 'Decimal' and
> > 'float'
>
> > Exception Location: C:\simuladores\..\simuladores\detector\views.py in
> > graph, line 32
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.