Skip to content
Huy Nguyen's Blog
Go back

django-i18n-fields: Multilingual Model Fields for Django

I ran multilingual content on django-localized-fields in production for a long time, but its hard PostgreSQL/HStore dependency and maintenance situation eventually pushed me to build a replacement: django-i18n-fields. The API is intentionally similar, so migrating is straightforward.

Table of contents

Open Table of contents

What makes it different

Quick example

# models.py
from i18n_fields import LocalizedCharField, LocalizedTextField

class Article(models.Model):
    title = LocalizedCharField(max_length=200, required=['en'])
    content = LocalizedTextField(blank=True)

# Usage
article = Article.objects.create(
    title={'en': 'Hello World', 'es': 'Hola Mundo'},
    content={'en': 'Content here', 'es': 'Contenido aqui'},
)

# Automatically uses the active language
print(article.title)  # "Hello World"

# Query by language
Article.objects.filter(title__en='Hello World')
Article.objects.order_by(L('title'))

And DRF just works:

from i18n_fields.drf import LocalizedModelSerializer

class ArticleSerializer(LocalizedModelSerializer):
    class Meta:
        model = Article
        fields = ['id', 'title', 'content']

# Returns: {"id": 1, "title": "Hello World", "content": "Content here"}

What’s next

Built-in translation services — Google Translate or LLM-based auto-translation (Gemini/ChatGPT/Claude) for your records.

I’ve been running this in production since migrating off django-localized-fields. Feedback and contributions welcome.


Share this post:


Previous Post
copit: Copy Source Code Into Your Project, shadcn/ui Style
Next Post
Python API Framework Benchmark: FastAPI vs Django vs Litestar on Real Database Workloads