S
S
stayHARD2016-03-22 11:58:18
Django
stayHARD, 2016-03-22 11:58:18

How to make the issuance of topics in the selected language?

Hi {{ user.username }}.
I want to make a form with a language picker in the admin panel (I use https://github.com/cordery/django-languages-plus), after selecting a language, issue all objects from my model (which has a connection with Languages)
model:

class Category(models.Model):
    name = models.CharField(max_length=255)
class Topic(models.Model):
    name = models.CharField(max_length=255)
    category = models.ForeignKey(Category)
class LocalizedTopic(models.Model):
    topic = models.ForeignKey(Topic)
    content = models.CharField(max_length=255)
    lang = models.ForeignKey(Language, default='en')

Ideally, get the following:
If I select English, then I should get a list of all Topics and an empty (or already filled in if there is a LocalizedTopic with that lang) editable input field.
Language: English
1. Привет [Hello] SAVE
2. Как дела? [How are you?] SAVE
3. Хорошо [] SAVE

I'm thinking about the implementation now, what can you suggest?
So far I have only found formfield_for_foreignkeysomething useful, but again I don’t know how to apply it, I’m customizing the admin panel for the first time :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Guest007, 2016-03-31
@Guest007

You didn't come from that end. You need to remove LocalizedTopic and use django-modeltranslation. Very convenient and well displayed in the admin panel (if grappelli is in the admin panel, then add more grappelli_modeltranslation). If you need to have multilingual versions of the site, then also django-localeurl.
django-rosetta will help to translate static texts (in templates and in source codes). This addition to jang's built-in i18n
django-modeltranslation mechanisms isn't the only option, but it works for me. Maybe you can find something else to suit your needs.
As always, Google drives and pedals.
And more djangopackages.com
Here, for example, on your question:
https://www.djangopackages.com/grids/g/i18n/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question