如何在 Django 管理界面的更改列表页面上添加自定义字段标题名称?

发布于 2024-09-16 19:37:05 字数 136 浏览 3 评论 0原文

我正在构建一个 django 站点,并在后端启用管理站点。我想更改各种模型字段的标题上显示的名称,而不实际更改字段的名称。有没有简单的方法可以做到这一点?我浏览了 django 网站,似乎找不到此信息。

有人知道这是否可以做到以及如何做到吗?

I'm building a django site with the admin site enabled on the backend. I want to change the names shown on the headers for the various model fields without actually changing the name of the fields. Is there an easy way to do this? I've browsed the django site and can't seem to locate this information.

Anyone know if this can be done and how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-09-23 19:37:05

您可以通过将 verbose_name 传递给字段定义

field_1 = models.CharField(verbose_name='Field One', max_length=255)

或简单地更改模型字段的显示名称

field_1 = models.CharField('Field One', max_length=255)

you can change the display name for a model field by passing verbose_name to the field definition

field_1 = models.CharField(verbose_name='Field One', max_length=255)

or simply

field_1 = models.CharField('Field One', max_length=255)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文