Django修复管理员复数 [英] Django fix Admin plural

查看:120
本文介绍了Django修复管理员复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在新的dev django版本的管理网站上将某些型号名称从类别更改为类别?
在旧版本(没有管理员网站和管理模式)中,您可以这么做;
http://www.the- dig.com/blog/post/customize-plural-name-django-admin/

How do I change some models name from "Categorys" to "Categories" on admin site in the new dev django version? In the old version (whithout admin sites and admin models) you could just do this; http://www.the-dig.com/blog/post/customize-plural-name-django-admin/

但是 - 现在在我的基于modeladmin的类中设置verbose_name_plural什么都不做。
任何人遇到相同的问题?

However - now setting verbose_name_plural inside my modeladmin based class does nothing. Anyone encouter the same issue?

推荐答案

好吧,这似乎是Meta类的方法仍然有效。
所以在你的模型中放置一个元类仍然会做到这一点:

Well well, it seems like the Meta class approach still works. So placing a meta class inside your model will still do the trick:

class Category(models.Model):
     class Meta:
        verbose_name_plural = "categories"

请注意,我们使用这个小写在这里,因为django在我们需要的时候足够聪明才能使用它。

Note that we use the lower case here, as django is smart enough to capitalize it when we need it.

我发现在模型类中设置了这个选项,而不是admin.py文件。
这是开发文档中描述的位置:

http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural

I find setting this option in model-class weird as opposed to the admin.py file. Here is the location in the dev docs where it is described:
http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural

这篇关于Django修复管理员复数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆