Tips for displaying fields and model names in the django model as Chinese characters: djangomodel
Simple Method:
Models. py
Copy codeThe Code is as follows:
Class IceCreamBar (models. Model ):
Title =
Models. CharField (max_length = 200, db_index = True, verbose_name = "name ")
Shell = models. CharField (max_length = 100, verbose_name = 'outpi ')
Filling = models. CharField (max_length = 100, verbose_name = 'init ')
Has_stick = models. BooleanField (default = True, verbose_name = 'have batch ')
Def _ unicode _ (self ):
Return self. title
Class Meta:
Verbose_name = "Popsicle"
Verbose_name_plural = "Popsicle s"
Using International translation functions:
Models
Copy codeThe Code is as follows:
From django. utils. translation import ugettext_lazy _
Class KarmaUser (AbstractUser ):
Karma = models. PositiveIntegerField (_ ("karma"), default = 0, blank = True)
Then set the translation text in the message.