Global decimal rounding options in Django

后端 未结 4 745
生来不讨喜
生来不讨喜 2021-01-24 11:14

Decimal numbers are by default rounded very unexpectedly, in order to make it work normally, it is needed to use ROUND_HALF_UP option.

>>>          


        
4条回答
  •  旧时难觅i
    2021-01-24 11:30

    Decimal doesn't have anything to do with Django, they are part of the standard python library. The getcontext function returns the context of the current thread, so if you're not doing anything funky, every request will be executed in one thread. That basically mean that setting the option in the settings.py file should be enough.

提交回复
热议问题