Internationalization of models in Django applications

My application will be available in two languages: English and German. The application will have several XType objects with a description field. How can I translate the XType description field? Does Django support this, or will I have to use another Django application?

class XType(models.Model):
    description = models.CharField(max_length=50)  
    def __unicode__(self):
        return self.description

class X(models.Model):
    type = models.ForeignKey(XType)
+3
source share
3 answers

Django does not provide direct support for translating model fields.

You need to find a way to deal with it either in Django or through plug-in applications (for example, django-easymode has already been sent or check http://blog.muhuk.com/2010/01/06/dynamic-translation-apps-for-django .html ).

, - :

class XType(models.Model):
    language = models.CharField(max_length=5)
    description = models.CharField(max_length=50) 

, , .

+1

django-easymode @i18n decorator, :

. Django Gettext. - - easymode .

0

Source: https://habr.com/ru/post/1784485/


All Articles