Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Category(models.Model):
- name = models.CharField()
- description = models.TextField()
- class CategoryTranslation(models.Model):
- name = models.CharField()
- description = models.TextField()
- category = models.ForeignKey(Category, related_name="translations")
- language = models.ForeignKey(Language)
- class Meta:
- unique_together = ('category', 'language')
- ## "the problem" [plain_text]
- I could to so I've a method on the category class like "translated_name"
- that take an argument language but the best solution
- - what I think - should be to pass some value like this:
- ## Example code
- LocaleSettings.language = "en"
- category = Category.objects.get(id=1)
- print category.name
- => "Hi You" (en / english)
- LocaleSettings.language = "de"
- category = Category.objects.get(id=1)
- print category.name
- => "Hallo Sie" (de / Deutch/German)
Add Comment
Please, Sign In to add comment