Skip to content

Auto-translate on save

When AUTO_TRANSLATE is enabled, django-traduire connects a post_save signal to all models registered with django-modeltranslation.

Enable

TRADUIRE = {
    ...
    "AUTO_TRANSLATE": True,
}

How it works

  1. A model instance is saved
  2. The post_save signal fires
  3. django-traduire checks for empty translation fields
  4. Empty fields are translated via the configured backend
  5. The instance is saved again with update_fields (only the translated columns)

The signal handler skips saves that include update_fields to avoid infinite recursion.

Selective auto-translate

If you only want auto-translate on specific models (not all registered ones), keep AUTO_TRANSLATE = False and connect manually:

# In your app's apps.py or ready() method
from django_traduire.signals import connect_model
from myapp.models import Article

connect_model(Article)

Performance note

Auto-translate makes an API call on every save. For bulk imports, use the management command instead:

python manage.py traduire myapp.Article