为整个 Django 模型定义一个详细名称
我想创建一个名为 Model 的模型。我很确定这是不允许的,所以我被迫使用其他术语来表示模型名称。假设我称之为 Mdl。然而,从用户的角度来看,我仍然想将该表称为模型。有没有办法像为模型字段定义详细名称一样为整个模型 Mdl 定义详细名称?在我的模板中,我在文档顶部引用当前表的名称:
{{ model }}
它从视图传递。如果我无法定义详细名称,那么我每次都必须调用某个函数来将 Mdl 的名称转换为该表的模型just。有人有替代建议吗?
I want to create a model named Model. I'm pretty sure this isn't allowed, so I'm forced to use some other term for the model name. Let's say I call it Mdl. However from the user perspective, I want to still refer to the table as Model. Is there a way to define a verbose name for the entire model Mdl the same way you can for model fields? In my templates, I reference the name of the current table at the top of the document:
{{ model }}
which gets passed from a view. If I can't define a verbose name, then I'm going to have to call some function every time to translate Mdl's name to Model just for that one table. Does anyone have an alternate suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要
Meta.verbose_name
< /a>You want
Meta.verbose_name