python - Cannot convert datetime.timedelta() to Decimal django -
i substracting 1 date , result again substracting 8 hours. after converting result in decimal. @ time of saving object getting error
cannot convert datetime.timedelta(0, 21600) decimal
code:
fm.extra_hours = (fm.trip_closing_date - fm.trip_starting_date) - timedelta(hours=8) #fm.extra_hours = time - timedelta(hours=8) st = fm.extra_hours print type(st) print st.days seconds = st.total_seconds() hours = int(seconds // 3600) print hours print type(hours) ext_hrs = float (hours) print ext_hrs print type(ext_hrs) if st.days < 0: st = 0 else: y="xyz" if ek>=1: fm.extra_kilometers = ek fm.extra_charge = ((((fm.vehical_type.per_extra_km_charge))*((fm.extra_kilometers)))+(((fm.vehical_type.per_extra_hour_charge))*(decimal(ext_hrs)))) fm.pure_amount = ((((fm.total_kilometer))*((fm.vehical_type.per_extra_km_charge)))+(((fm.vehical_type.per_extra_hour_charge))*(decimal(ext_hrs)))) fm.service_tax = (((fm.pure_amount)+(fm.driver_allownce_charge))*decimal(4.944))/decimal(100) fm.grand_total = ((fm.pure_amount)+(fm.driver_allownce_charge)+(fm.service_tax)) fm.amount_payeble_now = (fm.grand_total)-(fm.less_adavance) fm.save()
i dont know wrong doing? please me this.
full trace
typeerror @ /home/save_local_invoice/ cannot convert datetime.timedelta(0, 21600) decimal request method: post request url: http://localhost:8000/home/save_local_invoice/ django version: 1.7 exception type: typeerror exception value: cannot convert datetime.timedelta(0, 21600) decimal exception location: c:\python27\lib\decimal.py in __new__, line 658 python executable: c:\python27\python.exe python version: 2.7.8 python path: ['c:\\users\\magowa\\desktop\\magowa', 'c:\\users\\magowa\\desktop\\magowa', 'c:\\windows\\system32\\python27.zip', 'c:\\python27\\dlls', 'c:\\python27\\lib', 'c:\\python27\\lib\\plat-win', 'c:\\python27\\lib\\lib-tk', 'c:\\python27', 'c:\\python27\\lib\\site-packages'] server time: sat, 25 apr 2015 10:26:33 +0530 error on line fm.save()
it seems you're trying save timedelta object decimal. not possible without stating how decimal should interpret object. guess want fm.my_decimal_field = my_time_delta_object.total_seconds()
.
Comments
Post a Comment