[Fixed]-Make Django admin use translated field names

20👍

It turned out I was setting a translated version for name instead of verbose_name.

This works:

class Order(models.Model):
    OPTIONS = ( (0, _("Bank transfer") ), (1, _("Cash on delivery") ), )

    user = models.ForeignKey(User, verbose_name=_("User") )
    payment = models.IntegerField(choices=self.OPTIONS, verbose_name=_("Payment"))

9👍

TomA got the right answer.

But Django now takes the first argument as the verbose name of a field, except for the ForeignKey, ManyToManyField and OneToOneField field types.
So if you are lazy you can also write:

payment = models.IntegerField(_("Payment"), choices=self.OPTIONS)

You still have to use a keyword argument for the ForeignKey example, though:

user = models.ForeignKey(User, verbose_name=_("User"))

0👍

Are you perhaps using a custom ModelForm for this model (in admin.py)? You’ll need to add a gettext-ed value for the label of the fields you override.

Localizing app names is not possible, as of Django 1.0 – not sure of 1.1.

👤oggy

Leave a comment