Django translate data from the DB {{ profession }}

187 views Asked by At

Is it possible to translate DB entries? I have a dependent dropdown story that i need to translate. But i cant translate the dropdown fields, the fields come from other models and har hard coded. I can use HTML with JQ to achive this but i want to skip the manual labor to update the forms everytime new profession or professioncategories are added.

class Profession(models.Model):
    name = models.CharField(max_length=30),

    def __str__(self):
        return self.name

class Professioncategory(models.Model):
    profession = models.ForeignKey(Profession, on_delete=models.CASCADE)
    name = models.CharField(max_length=30)

    def __str__(self):
        return self.name

class Skills(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    active = models.BooleanField(_('Active'), default=True)
    profession = models.ForeignKey(Profession, on_delete=models.SET_NULL, null=True)
    professioncategory = models.ForeignKey(Professioncategory, on_delete=models.SET_NULL, null=True)
    posted_on = models.DateTimeField(_('Registrerad'), auto_now_add=True)
    updated_on = models.DateTimeField(_('last updated'), auto_now=True)
    years_of_exp = models.CharField(_('years of experiance'), max_length=20, choices=YEARS_OF_EXP, null=True, blank=True)
0

There are 0 answers