From a7bb0094fe09f2c48d42551f409ab69913005b55 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 19 Oct 2010 16:56:18 +0200 Subject: [PATCH] tickets: Use django.utils.format for number formatting. Using % interpolation with %f does not do localized number formatting (and the %d that was used did not do any floating point formatting at all). --- tickets/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tickets/models.py b/tickets/models.py index 5c5a819..cff9f23 100644 --- a/tickets/models.py +++ b/tickets/models.py @@ -1,6 +1,7 @@ # coding=utf-8 from django.db import models +from django.utils.formats import number_format # Create your models here. @@ -11,7 +12,7 @@ SHOW_CHOICES = [ ("vrijdag", "vrijdag 17 december, 20:00") TICKET_PRICE=7.5 -TICKETS_CHOICES = [ (n, u"%s (€%.2d)" % (n, n * TICKET_PRICE)) for n in range(1, 6)] +TICKETS_CHOICES = [ (n, u"%s (€ %s)" % (n, number_format(n * TICKET_PRICE,2))) for n in range(1, 6)] class Booking(models.Model): created = models.DateTimeField(auto_now_add=True, editable=False, verbose_name="Datum") @@ -26,8 +27,8 @@ class Booking(models.Model): price = property(_get_price) def __unicode__(self): - return u'#%s: %s - %s - %s kaart%s (€ %.2d)' % ( + return u'#%s: %s - %s - %s kaart%s (€ %s)' % ( self.pk, self.name, self.get_show_display(), self.tickets, "en" if self.tickets != 1 else "", - self.price) + number_format(self.price, 2)) -- 2.30.2