On 11.07.2011, at 10:58, stan wrote:

> Hi,
> 
> Maybe I missed something, but I didn't found any explanation in the
> doc about how to localize a date or a number in the python code side.
> Maybe I am totally wrong about wanting to do that but I can't see a
> solution to resolve the following problem in the template (where
> localization should be processed, I agree).
> 
> The typical use case is in the admin_list when you have a method in
> list_display or MyModel.__unicode__() that return a string with a date
> or a number. For example :
> 
> from django.utils.formats import localize
> 
> class Book(models.Model):
>    title = models.CharField(max_length=120)
>    date_published = models.DateField()
>    price = models.DecimalField(max_digits=8, decimal_places=2)
> 
>    def __unicode__(self):
>        return u"%s - %s $" % (localize(self.date_published),
> localize(self.price))
> 
> 
> Is that usage discouraged and the reason for not being documented ?
> 
> If not, do I have to open a ticket with a path for this page :
> https://docs.djangoproject.com/en/dev/topics/i18n/localization/ ?

Yeah, django.utils.formats.localize is the main function to localize
a value using the format localization engine from Python. The missing
documentation is a bug, IMO.

Jannis

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to