Hello,

I just tracked down what I thought was a bug in my invoicing
application to the default rounding used by python's decimal module.
The default, decimal.ROUND_HALF_EVEN will round 1.25 to 1.2 rather
than 1.3 for DecimalFields before putting them in the DB. This happens
in django.db.backends.util.format_number. I want to use
decimal.ROUND_HALF_UP, which is actually used by the floatformat
template filter at django.template.defaultfilters.floatformat.

My question: Is there any way to change the behavior of the decimal
module as currently called by django.db.backends.util.format_number so
that i can get the behavior I want without patching Django to pass the
setting to the quantize() call? I looked though the documentation for
the decimal module and tried

decimal.getcontext().rounding = decimal.ROUND_HALF_UP

in my settings.py, but that didn't make a difference.

Thanks for any comments/suggestions,

Vasili

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.

Reply via email to