django-hvad
django-hvad copied to clipboard
Document TranslatableInlineModelAdmin (and Stacked and Tabular)
In the Admin section we should document this classes.
I definitely agree - but I did not have the time to do so yet - if it is something you would be interested in doing, I would love to merge it in.
Kind regards,
Kristian
:+1: Some examples should be great. I can't even understand how normal TranslatableModel should work. I see the language tabs, but adding a new TranslatableModel in the admin wrting something in the 'Shared Fields' for the first tab and then click on the second tab (another language) will clear all fields and it shouldn't. Only after the first save that's it seems to work more or less. TranslatableInlineModelAdmin (and Stacked and Tabular) I can't figure out how it works. The Inline model shouldn't be the TranslatableModel but the [model]_translations table... I think!? It's just me that needs more input on this? :-(
I might be wrong, but I understand from the code that TranslatableInlineModelAdmin
intent is to inline translatable models in the admin of another related translatable model instance, the same way it works with Django admin.
Unfortunately I don't use Django admin in my project so I won't be really helpful with that specific part of hvad :(
No change, but for future references, I will address some of the questions of @kimus :
-
About the tabs behavior:
The tabs are not actual tabs, they are just tab-themed links. They reload the whole page, dismissing any edited value. If creating a new instance, the whole form is cleared. If editing an existing one, all fields are reloaded from database.
Implementing proper tabs would require some javascript and heavier customization of forms. At the moment, the only way to do this is to set up your own form, and use a
TranslationFormset
along with some custom javascript. I do this in my own projects, maybe I could take some time to implement it in a more generic way for hvad at some point. -
TranslatableInlineModelAdmin
, to the best of my knowledge, is not intended for translation editing, but for editing multiple instances of a translatable model, all of them in only one language. Like, you have an Author admin page where you can edit names and biography in several languages, and you would useTranslatableInlineModelAdmin
to inline the admin for Book instances connected to current author.