While trying to implement a translated version of a website, I came across the following problem:
Let say I have a model defined like that:
class Model(models.model)
name=models.CharField(max_length=10)
...
To create some data (which are later displayed on a web page), I use a special view that includes lines like:
Model.objects.create(name = "testName",...)
I tried to implement the translation with the following code:
Model.objects.create(name = _("testName"),...)
If I import ugettext as _ , it just put the translated value of “testName” in the database.
If I import ugettext_lazy as _, I have an InterfaceError (more precisely Error binding parameter X - probably unsupported type.
I was wondering if such an initialization is possible of if I have to find some workarounds.
Thanks in advance.
Just store the english version in the db and only call ugettext/_lazy during output. This obviously only works as long as translations for those strings exist, otherwise it will display the english version either way…