django-parler icon indicating copy to clipboard operation
django-parler copied to clipboard

Using a language code as a parameter when creating a form

Open mchccc opened this issue 9 years ago • 1 comments

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)?

mchccc avatar Mar 20 '15 11:03 mchccc

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.

vdboor avatar Apr 09 '15 21:04 vdboor