django-parler
django-parler copied to clipboard
Using a language code as a parameter when creating a form
Would it be possible to use a language code parameter when building a TranslatableModelForm, so that the resulting form will display and save the translated fields, maybe creating them if they don't exist?
Or is the expected workflow to use with switch_language(model, lang): MForm(instance=model)
?
Looking at the code, I'm not sure what you mean. Are you referring to editing objects, or creating new objects?
Edited objects are always rendered in their active language, which makes sense to me. Overriding that happens on the model (e.g. model.set_current_language('..')
). You only need to use switch_language
if you want to temporary change a language, and then revert to the previous state.