-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParentalManyToManyField and translations #534
Comments
Was able to solve it by taking advantage of limit_choices_to on the ParentalManyToManyField. It's a hack but I had to map it just the objects with locale_id="1".
Then in my class:
|
I think it's a good hack if you don't need the translated version displayed on the back-office. Why don't you use an inline panel? Checkboxes are important in your case? |
I used this solution with a slight modification. Instead of hard coding the language ID, I use whatever the language of the user is. This isn't without its problems (i.e. if a user's browser is in a language not supported), but for us it works fine. from django.utils.translation import get_language
def limit_country_choices():
limit = models.Q(locale__language_code=get_language())
return limit |
Related Wagtail issue - wagtail/wagtail#8821 |
Hi there,
I have a translatable snippet (lets call it "items") that editors can associate to a page using checkboxes.
To achieve that I use a model with a ParentalManyToManyField. That way, editors can associate items to a page.
Wagtail Localize works perfectly to translate the items snippet.
Issue: when editing the page, the items listed are not scoped to the selected language. Instead, editors have the list of all items in all languages (items are duplicated).
For example if my website is in English and French, if I edit a page in english, I will have the list of items in English and in French as well.
The solution I found is to replace the ParentalManytoManyField with an inline panel (following this tutorial -> https://www.accordbox.com/blog/wagtail-tip-1-how-replace-parentalmanytomanyfield-inlinepanel/) and making the intermediate model a translatable model.
I don't know if it's the only solution, but for my case it would have been more convenient to stick with a ParentalManyToManyField.
The text was updated successfully, but these errors were encountered: