[fixed top-posting] On Thu, Feb 26, 2009 at 09:31, Matej <matej.pun...@gmail.com> wrote: > On Feb 26, 3:38 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: >> On Thu, Feb 26, 2009 at 4:36 AM, Matej <matej.pun...@gmail.com> wrote: >> >> > Hello. >> > I would like to get my translated text from ugettext_lazy() result. >> > How can I do that? >> >> > Example: >> >http://dpaste.com/1744/ >> >> > #models.py >> > RATING_CHOICES = ( >> > ('0', _('I don\'t know')), >> > ('1', _('Very bad')), >> > ('2', _('Bad')), >> > ('3', _('OK')), >> > ('4', _('Good')), >> > ('5', _('Excelent')), >> > )
[...] >> Perhaps you're looking for this >> method:http://docs.djangoproject.com/en/dev/ref/models/instances/#get-foo-display > This looks like it should work but it does not. > WebStoreRating fields delivery and ui have defined > choices=RATING_CHOICES > >>>> r = WebStoreRating.objects.filter(pk=1) >>>> r = r[0] >>>> r.get_delivery_display() > 3 >>>> r.get_ui_display() > 3 Just a guess: you're using some kind of *integer* model field but since your choices are tuples with *strings* as the first element. Use integers for the first element of each tuple instead: RATING_CHOICES = ( (0, _('I don\'t know')), (1, _('Very bad')), (2, _('Bad')), (3, _('OK')), (4, _('Good')), (5, _('Excelent')), ) Arien --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---