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

Fallback value explained #567

Open
schumannd opened this issue Sep 3, 2020 · 1 comment
Open

Fallback value explained #567

schumannd opened this issue Sep 3, 2020 · 1 comment

Comments

@schumannd
Copy link

I am having trouble understanding fallback behavior of this project.

If I translate e.g. a field "name" into "name_en" and "name_de", but leave both empty. Should the value in the "name" column be displayed?

I noticed that after running the migrations all translated fields were displayed as empty in the admin. Only after running

./manage.py update_translation_fields

Were the default strings displayed. This is because all strings in "name" were copied into "name_de".

Is there a fallback setting, that would cause the content of the "name" column to be displayed if the other columns are empty?

@rubenanapu
Copy link

I just had the same requirement (or expected behavior) as yours, @schumannd

What I did was the following:

Just modified the last line of TranslationFieldDescriptor.__get__ to the following

-           return default
+           return default or instance.__dict__[self.field.name]

In my tests, it seems to be working as I expected.

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

2 participants