django模型中的字段和model名显示为中文小技巧分享

1219次阅读  |  发布于5年以前

简单方法:

models.py

复制代码 代码如下:

class IceCreamBar(models.Model):
title =

models.CharField(max_length=200,db_index=True,verbose_name="名称")  
    shell = models.CharField(max_length=100,verbose_name='外皮')  
    filling = models.CharField(max_length=100,verbose_name='内含')  
    has_stick = models.BooleanField(default=True,verbose_name='有没有棍')

    def __unicode__(self):  
        return self.title

    class Meta:  
        verbose_name = "冰棒"  
        verbose_name_plural = "冰棒s"  

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8