0

I am creating a Django application where users will have different possible groups to manage their permissions.

I would like this application to be translatable in the future, but the group names are not translatable by default. How can I make this possible? I have thought about a few possible solutions, but I can't decide which one is best.

  • Replace the template where the groups are displayed and translate the group names.
  • Replace the group templates and change the __str__ method.

Can you think of another solution?

Which one do you think is the best?

Raida
  • 1,206
  • 5
  • 17

1 Answers1

0

I finally decided to override the __str__ method of the Group model like that (in models.py)

from django.contrib.auth.models import Group
from django.utils.translation import gettext as _

Group.__str__ = lambda self : _(self.name)
Raida
  • 1,206
  • 5
  • 17