Auto-translate on save¶
When AUTO_TRANSLATE is enabled, django-traduire connects a post_save signal to all models registered with django-modeltranslation.
Enable¶
How it works¶
- A model instance is saved
- The
post_savesignal fires - django-traduire checks for empty translation fields
- Empty fields are translated via the configured backend
- 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: