5

我有一个要翻译的表格:

模型.py:

class Show(models.Model):
    discount_tickets = models.IntegerField("Discount Tickets")
    regular_tickets = models.IntegerField("Regular Tickets")
    afillate_price = models.IntegerField("Afillate Price")
    user_price = models.IntegerField("User Price")
    start_time = models.CharField("Event Time", max_length=20)
    sale_end_time = models.CharField("Sale End Time", max_length=20) 

    def __unicode__(self):
        return unicode(self.discount_tickets)

class ShowForm(ModelForm):
    pass

    class Meta:
        model = Show 

如何翻译字段名称?

4

1 回答 1

10
from django.utils.translation import ugettext_lazy as _

class Show(models.Model):
    discount_tickets = models.IntegerField(_("Discount Tickets"))
    regular_tickets = models.IntegerField(_("Regular Tickets"))
    afillate_price = models.IntegerField(_("Afillate Price"))
    user_price = models.IntegerField(_("User Price"))
    start_time = models.CharField(_("Event Time"), max_length=20)
    sale_end_time = models.CharField(_("Sale End Time"), max_length=20) 
于 2013-04-08T08:18:23.730 回答