Accessing fields

Translatable fields can be used like regular fields:

>>>object=MyModel.objects.all()[0]>>>object.get_current_language()'en'>>>object.titleu'cheese omelet'>>>object.set_current_language('fr')# Only switches>>>object.title="omelette du fromage"# Translation is created on demand.>>>object.save()

Internally, django-parler stores the translated fields in a separate model, with one row per language.

Filtering translations

To query translated fields, use the .translated() method:

MyObject.objects.translated(title='cheese omelet')

To access objects in both the current and possibly the fallback language, use:

MyObject.objects.active_translations(title='cheese omelet')

This returns objects in the languages which are considered “active”, which are:

The current language

The fallback language when hide_untranslated=False in the PARLER_LANGUAGES setting.

Changing the language

The queryset can be instructed to return objects in a specific language: