Django / Python 计算
我正在构建一个小项目,允许用户获得项目资金。
一个项目有一个名为“amount_raised”的字段,它可能包含一个整数,例如“123.34”,
当通过 paypal 成功付款时,您会收到 ipn_obj
,其中包含一些财务信息,即 ipn_obj.mc_gross
可能是“10.23”,
我如何在 django 中执行计算以获得其总值?
这是我第一次在 django 中处理计算,所以请耐心等待。
如果我尝试将它们转换为整数,我会收到错误 invalidliteral for int() with base 10
非常感谢您的帮助。
I am building a small project that allows a user to get funding for a project.
A project has a field called "amount_raised" that might house an integer such as "123.34"
when a successful payment is done through paypal you receive the ipn_obj
of which one contains some financial info, i.e. ipn_obj.mc_gross
which might be "10.23"
how do I perform a calculation in django to get the total value of that?
It's the first time I have dealt with calculations in django so bear with me.
If I try converting them to integers I get an error invalid literal for int() with base 10
Your help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像 123.45 这样的数字不是整数。您需要的是 DecimalField。用法示例:
A number like 123.45 is not an integer. What you need is a DecimalField. Example usage: