Skip to main content

DJANGO i18n FIELDS

PyPI Code Coverage Test Checked with mypy Checked with pyright

A modern Django package providing structured internationalization (i18n) for model fields. Store and manage multilingual content directly in your Django models using a clean, database-agnostic approach.

Improved alternative to django-localized-fields - Works with all databases, not just PostgreSQL.

Key Features

🌍 Comprehensive Field Types

CharField, TextField, IntegerField, FloatField, BooleanField, FileField, UniqueSlugField, and MartorField (Markdown) with multilingual support

🎯 Database Agnostic

Works with PostgreSQL, MySQL, SQLite - any database that supports JSONField

📝 Rich Admin Integration

Beautiful tab and dropdown interfaces for managing translations in Django admin, with Markdown editor support via martor

🔍 Powerful Querying

Filter, order, and annotate queries with language-specific values using L() expressions

🚀 Django REST Framework Support

Automatic serialization with LocalizedModelSerializer - returns simple values in the active language

🛠️ Full Type Safety

Complete type hints with mypy and pyright compatibility

Quick Start

Installation

pip install django-i18n-fields

# With Markdown editor support (martor)
pip install django-i18n-fields[md]

Basic Usage

# models.py
from django.db import models
from i18n_fields import LocalizedCharField, LocalizedTextField

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

# Create with translations
article = Article.objects.create(
    title={'en': 'Hello World', 'es': 'Hola Mundo'},
    content={'en': 'Content in English', 'es': 'Contenido en español'}
)

# Access in current language
print(article.title)  # Automatically uses active language

# Query by specific language
Article.objects.filter(title__en='Hello World')

# Order by translated field
from i18n_fields import L
Article.objects.order_by(L('title'))

Django Admin

# admin.py - Option 1: Using the base class (recommended)
from i18n_fields import LocalizedFieldsAdmin

@admin.register(Article)
class ArticleAdmin(LocalizedFieldsAdmin):
    list_display = ['title', 'created_at']
    # Automatic tab/dropdown widgets for all localized fields!

# admin.py - Option 2: Using the mixin with your own base class
from django.contrib import admin
from i18n_fields import LocalizedFieldsAdminMixin

@admin.register(Article)
class ArticleAdmin(LocalizedFieldsAdminMixin, admin.ModelAdmin):
    list_display = ['title', 'created_at']

Django REST Framework

# serializers.py
from i18n_fields.drf import LocalizedModelSerializer

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

# Returns: {"id": 1, "title": "Hello World", "content": "..."}
# Automatically uses active language!

Configuration

# settings.py
INSTALLED_APPS = [
    # ...
    'i18n_fields',
]

LANGUAGES = [
    ('en', 'English'),
    ('es', 'Spanish'),
    ('fr', 'French'),
]

I18N_FIELDS = {
    'DISPLAY': 'tab',  # or 'dropdown' for admin
    'FALLBACKS': {
        'en-us': ['en'],
        'es-mx': ['es'],
    },
}

Why Django i18n Fields?

vs django-localized-fields

  • ✅ Works with all databases (not just PostgreSQL)

  • ✅ Actively maintained with regular updates

  • ✅ Better type hints and IDE support

  • ✅ Built-in DRF support with automatic serialization

  • ✅ Enhanced admin UI with tab/dropdown modes

  • ✅ Query expressions (L() and LocalizedRef)

  • ✅ Comprehensive documentation

Documentation

📚 Full documentation: https://django-i18n-fields.readthedocs.io/

Quick Links:

Requirements

  • Python 3.10+

  • Django 5.0+

  • Django REST Framework 3.0+ (optional, for DRF integration)

  • martor (optional, for Markdown editor support — install with pip install django-i18n-fields[md])

Contributing

We welcome contributions! Please see our Contributing Guide for detailed instructions.

Development Setup:

git clone https://github.com/huynguyengl99/django-i18n-fields.git
cd django-i18n-fields
uv venv
source .venv/bin/activate
uv sync --all-extras
pytest

License

MIT License - see LICENSE for details.

Support

Metadata

Release files for django-i18n-fields 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-i18n-fields 1.2.1
File Size Uploaded Provenance Actions
django_i18n_fields-1.2.1.tar.gz 37.4 kB With provenance Details for django_i18n_fields-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-i18n-fields 1.2.1
File Interpreter ABI Platform Actions
django_i18n_fields-1.2.1-py3-none-any.whl Python 3 none any Details for django_i18n_fields-1.2.1-py3-none-any.whl

Total release size: 91.5 kB

Release files / django_i18n_fields-1.2.1.tar.gz

Download URL django_i18n_fields-1.2.1.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ce54166445c24f5a8a342f83664b2af7b91dde3cee55115db6dd8aa9987884c7
BLAKE2b-256 checksum
How to use checksums
d618af6689ce2f704fab7bfcd055bdec26505cc00f42ebfc8458414d46eaef85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / django_i18n_fields-1.2.1-py3-none-any.whl

Download URL django_i18n_fields-1.2.1-py3-none-any.whl
Size 54.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6410866fa0cd89c0bda24ca94a56a46293ecb6625d0169b6c245dff6b5d8a67
BLAKE2b-256 checksum
How to use checksums
c96bb8deac5fa6440f493d766463cbdb397973fa9ac99288c04b4dfebf7fb58f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Security for django-i18n-fields 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_i18n_fields-1.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page