To solve this you can import format and pass the result of total() to it like:
from django.conf import settings
from django.utils.numberformat import format
...
def total(self):
total = self.total_income + self.total_fee
return format(total, settings.DECIMAL_SEPARATOR, 2)
hope it helps! Have a nice weekend!
Denis.
On Sat, Feb 4, 2012 at 9:52 AM, Vittorino Parenti <vparenti@thundersystems.it> wrote:
-- Hello,
i've a problem with number format localization. This is an example of
my model and admin:
MODEL
------------
class Procedure(models.Model):
....
total_income = models.DecimalField (
default = 0,
max_digits = 11,
decimal_places = 4,
verbose_name = _("Total Income"),
)
total_fee = models.DecimalField (
default = 0,
max_digits = 11,
decimal_places = 4,
verbose_name = _("Total Fee"),
)
....
def total(self):
return self.total_income + self.total_fee
ADMIN
-----------
class ProcedureAdmin(dmin.ModelAdmin):
list_display = (..., 'total_income', 'total_fee', 'total', ...)
output is:
... | 35,22 | 9,28 | 45.50 | ...
with comma in first two cases and dot then.
How can I do?
Thanks in advance,
Vittorino
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment