Skip to content
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

TranslatableAdmin exception when no translations on default language #302

Open
Marcon opened this issue Sep 20, 2021 · 2 comments
Open

TranslatableAdmin exception when no translations on default language #302

Marcon opened this issue Sep 20, 2021 · 2 comments

Comments

@Marcon
Copy link

Marcon commented Sep 20, 2021

Hi. I have some simple configuration like this

LANGUAGES = (
    ('ru', 'RU'),
    ('en', 'EN'),
    ('kz', 'KZ'),
)

PARLER_LANGUAGES = {
    None: (
        {'code': 'ru'},
        {'code': 'en'},
        {'code': 'kz'},
    ),
    'default': {
        'fallbacks': ['ru', 'en', 'kz'],
        'hide_untranslated': False,
    }
}

Default language is russian.
I have some translated models in my app and editing translation trough admin site using TranslatableAdmin
Everything works fine when I starting translation from default language, and I can create russian translation first and after this create english or kazakh language on any order.
But if I create english(or kazakh) translation first and probably leave only english translation for this entry, when I attempting switch to english tab and edit entry, I have exception "parler.models.DoesNotExist: MyModel does not have a translation for the current language!" and I cannot edit entry until default language translation created

@ersul4ik
Copy link

ersul4ik commented Oct 3, 2022

@Marcon I think you have to change 'None' (PARLER_LANGUAGES key) to your SITE_ID.

@yahyrparedes
Copy link

LANG es
Hay multiples soluciones para este error estan descritan dentro de su documentación:
https://django-parler.readthedocs.io/en/stable/advanced/fallback.html

La mas rapida y comun es agregar esto al modelo base:

    def __str__(self):
        try:
            return self.name
        except TranslationDoesNotExist:
            return ''

LANG en
There are multiple solutions for this error that are described within their documentation:
https://django-parler.readthedocs.io/en/stable/advanced/fallback.html

The fastest and most common is to add this to the base model:

     def __str__(self):
        try:
            return self.name
        except TranslationDoesNotExist:
            return ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants