i'm looking for a way to tranlate my models choices. There is my model:
class CompteFinancier(models.Model):
STATUS__OUI_NON = (
('--------', '--------'),
(STATUS_OUI, 'Cas num 1'),
(STATUS_NON, 'Cas num 2')
)
Cabinet = models.CharField(blank=True, max_length=200, null=True)
requis_pour_deposer = models.CharField(blank=True, max_length=200, null=True)
credibilite_cabinet= models.CharField(choices=STATUS__OUI_NON)
Can someone show me show to trans my choices cas please?
This is how you specify the text that needs translation in your model
from django.utils.translation import gettext_lazy as _
class CompteFinancier(models.Model):
STATUS__OUI_NON = (
('--------', '--------'),
(STATUS_OUI, _('Cas num 1')),
(STATUS_NON, _('Cas num 2'))
)
cabinet = models.CharField(blank=True, max_length=200, null=True)
requis_pour_deposer = models.CharField(blank=True, max_length=200, null=True)
credibilite_cabinet = models.CharField(choices=STATUS__OUI_NON)
The full documentation for django translations can be found here . See this answer for a step by step guide for setting up internationalization in django
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.