在 settings.py
中载入入中间件(加入下面这个):
django.middleware.locale.LocaleMiddleware
在定义 Model
类的时候,在 Meta
里面显式指定 verbose_name
和 verbose_name_plural
即可指定该模型在 Admin 里面显示的别名。
class Item(models.Model):
# ... 这里定义各种字段
class Meta:
verbose_name='物件' # 单数形式
verbose_name_plural='物件' # 这个是复数形式
类似,只需要在模型字段定义的命名参数中指定 verbose_name
即可,这次没有复数:
class Item(models.Model):
item_name = models.CharField( verbose_name='物件名称',max_length=50, )
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有