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"))
- Django – Access ForeignKey value without hitting database
- How can I specify a database for Django Tests to use instead of having it build it every time?
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
- Converting a django ValuesQuerySet to a json object
- How do I remove the square brackets at the end of a JS variable name during AJAX calls?
Source:stackexchange.com