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.
__str__
method.Can you think of another solution?
Which one do you think is the best?
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)