Localized foreign key field?
winged opened this issue · 2 comments
In one of my projects, it would be very useful to have a localized foreign key field type.
For example, when accompanying a localized model with some images that reside in their own model:
class Product(models.Model):
name = LocalizedField()
image = HypotheticalForeignKey("Image")
class Image(models.Model):
name = LocalizedField()
data = FileField()
I realize this specific usecase could be implemented by using a LocalizedFileField
, but nor all images are localized in my case, so they are managed completely separate.
Just chiming in because I'm solving a similar problem now and evaluating model i18n solutions. If you don't like the idea of LocalizedFileField, then why not just use a ManyToMany relationship? Because this is what you have when you add languages (or another property) to a foreign key.
You could either use a through model (and add the language there) or add the language code to the Image model depending on what makes sense. (And, of course,in that case you don't want name to be a LocalizedField.)
You could accomplish this by building on top of LocalizedIntegerField
. Feel free to open a PR if you have a working implementation.