On Nov 9, 4:28 am, "Aidas Bendoraitis" <[EMAIL PROTECTED]> wrote: > Actually this could be integrated into the core. > When you create a model, you could add translatable=True to fields > that have to be in the language-specific table. > When you make selections, you would need to set the language name in > the following or a similar way: > MyModel.objects.by_language("EN").all() > MyModel.objects.by_language("EN").order_by('title') > which would form queries like: > SELECT * FROM myapp_mymodel INNER JOIN myapp_mymodel_translatable ON > myapp_mymodel.id = myapp_mymodel_translatable.id ORDER BY title
What about using generic relations for this? You could have something like this: class I18NText(models.Model): language = models.ForeignKey(Language) field = models.CharField(maxlength=25) translated_text = models.TextField() content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() translated_object = models.GenericForeignKey() def __str__(self): return self.translated_text class ModelNeedingTranslation(models.Model): foo = models.IntegerField() bar = models.TextField() translations = models.GenericRelation(I18NText) Then you can add translations of field(s) by doing: a = ModelNeedingTranslation(1, 'nothing') a.translations.create(field='bar', translated_text='nada', language=Language('Spanish')) You can get the text for a specific translation like this: a.translations.filter(field='bar', language=Language('Spanish')) David Blewett --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---