翻译 Django 组名
我正在创建一个 Django 应用程序,其中用户将有不同的可能组来管理他们的权限。
我希望这个应用程序将来可以翻译,但默认情况下组名称不可翻译。我怎样才能使这成为可能?我考虑了几种可能的解决方案,但无法决定哪一种是最好的。
- 替换显示组的模板并翻译组名称。
- 替换组模板并更改
__str__
方法。
你能想到另一个解决方案吗?
您认为哪一款最好?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终决定像这样重写 Group 模型的 __str__ 方法(在 models.py 中)
I finally decided to override the
__str__
method of the Group model like that (inmodels.py
)