Let the fields and model names in Django model be displayed in Chinese

Time:2021-11-18

Simple method:

models.py

class IceCreamBar(models.Model):
    title = 

    Models. Charfield (max_length = 200, db_index = true, verbose_name = "name")
        Shell = models.charfield (max_length = 100, verbose_name = 'skin')
        Filling = models.charfield (max_length = 100, verbose_name = 'included')
        has_ Stick = models. Boolean field (default = true, verbose_name = 'have stick')

        def __unicode__(self):
            return self.title

        class Meta:
            verbose_ Name = "Popsicle"
            verbose_ name_ Plural = "popsicle s"

Take advantage of international translation functions:

models

from django.utils.translation import ugettext_lazy as _

class KarmaUser(AbstractUser):
karma = models.PositiveIntegerField(_("karma"),default=0,blank=True)

Then set the translation text in message