Sam
Sam

Reputation: 501

Django: Verbose name of related model not translated

I am using ugettext to translate a Category model's verbose_name. This works fine in admin when adding new objects, however, when using Category as in a one-to-many relationship with Post, the Category's verbose_name is neither translated in the list filter nor the change form of Post.

How can I correct this?

Upvotes: 2

Views: 2596

Answers (1)

Filip Dupanović
Filip Dupanović

Reputation: 33690

I just checked the official docs on Verbose field names. ForeignKey does not not accept the verbose_name positional argument.

I think what fviktor tried to suggest was to set the verbose_name attribute in your model's Meta class:

class Category(Model):
    class Meta:
        verbose_name = _lazy(u'Category')
        verbose_name_plural = _lazy(u'Categories')

Upvotes: 4

Related Questions