[Answered ]-Django: could not convert string to float: ''

1πŸ‘

βœ…

It looks like you are getting an empty string '' when trying to convert item['price'] into a float.

>>> float('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: ''

Make sure that item['price'] has a valid value before converting it to a float. From the error traceback you provided, it seems request.session['cart_data_obj'] is not having the right information. At some point where you set session['cart_data_obj'], the value for key "price" is being set to the empty string ''.

Leave a comment