Unable to make a simple calculation in django -
i have view , trying perform simple mathematical calculation , getting error throwing me off.
so have method take in 2 variabes, decimal value , integer. want take numbers , divide decimal integer. getting following error , dont know why...
this method
def spliteven(record, amount): record_count = record.count print(record_count) print(amount) split_amount = amount/record_count print(split_amount) rounded_amount = round(split_amount, 2) print (record_count) print (amount) print (split_amount) return rounded_amount
this error message:
unsupported operand type(s) /: 'str' , 'int' c:\users\omarjandali\desktop\opentab\opentab\tab\views.py in addtransaction taxsplit = spliteven(record, amount) c:\users\omarjandali\desktop\opentab\opentab\tab\views.py in spliteven split_amount = amount/record_count
here comes print statements:
[25/jul/2017 16:14:10] "get /static/css/blog.css http/1.1" 404 1649 6 6 6.00 [25/jul/2017 16:15:05] "post /39/72/add_transaction/ http/1.1" 500 83164
from decimal import decimal def spliteven(record, amount): record_count = decimal(record.count) split_amount = decimal(amount)/record_count rounded_amount = round(split_amount, 2) return rounded_amount
Comments
Post a Comment