Skip to content

Commit

Permalink
in admin, render price as string to prevent bogus farmatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Mar 18, 2018
1 parent 6b62f38 commit 2c5435c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/myshop/admin/i18n_polymorphic.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ class ProductAdmin(PolymorphicSortableAdminMixin, PolymorphicParentModelAdmin):
list_max_show_all = 1000

def get_price(self, obj):
return obj.get_real_instance().get_price(None)
return str(obj.get_real_instance().get_price(None))
get_price.short_description = _("Price starting at")
2 changes: 1 addition & 1 deletion example/myshop/admin/polymorphic_.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ class ProductAdmin(PolymorphicSortableAdminMixin, PolymorphicParentModelAdmin):
list_max_show_all = 1000

def get_price(self, obj):
return obj.get_real_instance().get_price(None)
return str(obj.get_real_instance().get_price(None))
get_price.short_description = _("Price starting at")
1 change: 1 addition & 0 deletions shop/serializers/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, *args, **kwargs):

def get_price(self, product):
price = product.get_price(self.context['request'])
# TODO: check if this can be simplified using str(product.get_price(...))
if six.PY2:
return u'{:f}'.format(price)
return '{:f}'.format(price)
Expand Down

0 comments on commit 2c5435c

Please sign in to comment.