0

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 ?

Alvine
  • 3
  • 2

1 Answers1

1

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

AdonisN
  • 489
  • 4
  • 12