TypeError at /admin/product/subitem/

Create issue
Issue #47 resolved
Former user created an issue

{{{ Traceback (most recent call last): File "/usr/lib/python2.5/django/template/init.py" in render_node 723. result = node.render(context) File "/usr/lib/python2.5/django/template/init.py" in render 883. dict = func(*args) File "/usr/lib/python2.5/django/contrib/admin/templatetags/admin_list.py" in result_list 201. 'results': list(results(cl))} File "/usr/lib/python2.5/django/contrib/admin/templatetags/admin_list.py" in results 196. yield list(items_for_result(cl,res)) File "/usr/lib/python2.5/django/contrib/admin/templatetags/admin_list.py" in items_for_result 128. attr = getattr(result, field_name) File "/usr/lib/python2.5/satchmo/product/models.py" in _get_fullPrice 373. price_delta += Decimal(option.price_change)

TypeError at /admin/product/subitem/ Cannot convert float to Decimal. First convert the float to a string }}}

Shows up with the demo data.

Reported by jshaffer

Comments (3)

  1. Former user Account Deleted

    What database are you using?

    I don't have the code in front of me at the moment, but this has been fixed other places by doing Decimal(str(value)). How are other django apps dealing with this? We keep running into this problem in different places in the code. If I remember correctly Mysql returns Decimal objects, but sqlite (at least) seems to return floats.

  2. Chris Moffitt repo owner

    I see one more place where we need to wrap the values so that a Decimal is always returned.

    In the Item class, around line 185, there is some code to return the price as a decimal. We need to implement a similar change for OptionItem so that we don't call price_change but some other property (maybe get_price_change).

  3. Log in to comment