I would highly recommend django-hvad.
Here's your models.py as an hvad TranslatableModel
:
class Picture(TranslatableModel):
translations = TranslatedFields(
title = models.CharField(max_length=30, null=True, blank=True)
tagline = models.CharField(max_length=30)
description = models.CharField(max_length=100)
)
gallery = models.ForeignKey(Gallery)
image = models.ImageField(upload_to="uploads/images/")
page_link = PageField(related_name="Page", null=True, blank=True)
def __unicode__(self):
return self.lazy_translation_getter('title', self.pk)
As mentioned in the docs, this app is still in Beta but I've used it in many production environments and works good.
One thing to keep in mind is that it does bring a few limitations.
The way it works is it creates a model called PictureTranslation
(or something like that) which will have your three fields title
, tagline
, description
and a ForeignKey
to Picture
.
You can still do picture_instance.title
as long as the picture_instance is language aware.
If you would like, I can give a better explanation based on your specific use case.