django-localekit
django-localekit is a Django library that adds database-backed model translations. It works entirely through the database with an optional .po file workflow and optional automatic translation via external providers or AI. Optional Django REST Framework integration is available for serving translations in APIs.
Key features
- Non-destructive translations — all translations are stored in a separate
Translationmodel; your original field values are never modified. - DB-first workflow — the system works entirely through the database. Translations can be created and managed via the Django admin without ever touching a file.
- Admin support — the
TranslationInlineclass lets you manage translations directly in the Django admin. - Optional PO file workflow — if you need to work with a translation agency or integrate with an existing gettext setup,
dlk_makemessagesanddlk_update_databaseexport and import standard.pofiles. This is entirely optional. - Automatic translation — the
dlk_translate_modelscommand translates all empty (or all) fields via a configurable provider: Google Translate v2/v3, AWS Translate, DeepL, or any custom provider including AI language models such as GPT-4o. - Extensible provider system — implementing a custom translation provider requires only a single class with two attributes and one method.
- DRF integration — optional serializers serve translated content in APIs based on the active request language. See DRF.
Quick example
# models.py
from django_localekit.models import TranslatableModel
class Article(TranslatableModel):
title = models.CharField(max_length=200)
body = models.TextField()
translatable_fields = ["title", "body"]
Use get_translation(article, "title") in views or templates, or add TranslationInline in the admin. For APIs, see DRF → Serializers.
# serializers.py (optional)
from django_localekit.drf.serializers import TranslatableDBSerializer
class ArticleSerializer(TranslatableDBSerializer):
class Meta:
model = Article
fields = "__all__"
A GET /articles/1/ request with Accept-Language: es returns the Spanish translation automatically.
Navigation
- Installation — install and configure the package.
- Usage — models, admin, and the utility function.
- DRF — optional Django REST Framework integration (serializers).
- Commands — management commands with example PO file output.
- Translation Providers — built-in providers and writing your own (including AI models).
- Development — running the test suite and previewing these docs locally.