Structured internationalization fields for Django models.
Project description
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, and UniqueSlugField 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
- 🔍 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
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)
Contributing
We welcome contributions! Please see our Contributing Guide.
Development Setup:
git clone https://github.com/huynguyengl99/django-i18n-fields.git
cd django-i18n-fields
pip install -e ".[dev]"
pytest
License
BSD 3-Clause License - see LICENSE for details.
Support
🐛 Bug Reports: GitHub Issues
💬 Questions: GitHub Discussions
📖 Documentation: https://django-i18n-fields.readthedocs.io/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_i18n_fields-1.1.0.tar.gz.
File metadata
- Download URL: django_i18n_fields-1.1.0.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91ef0066ea98cb7cb16401c5e76981299b5fe6cefe250b6f6f514314168c0626
|
|
| MD5 |
80dda0c1dd29f183b6572af1dd03df96
|
|
| BLAKE2b-256 |
65b8ef898882f149ea470545209faf83db51b502226c352fdbcd2a5826e80581
|
Provenance
The following attestation bundles were made for django_i18n_fields-1.1.0.tar.gz:
Publisher:
publish.yml on huynguyengl99/django-i18n-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_i18n_fields-1.1.0.tar.gz -
Subject digest:
91ef0066ea98cb7cb16401c5e76981299b5fe6cefe250b6f6f514314168c0626 - Sigstore transparency entry: 884068894
- Sigstore integration time:
-
Permalink:
huynguyengl99/django-i18n-fields@53ca9c8f2e12c0eff8964721fe9e403d94967c3a -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/huynguyengl99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@53ca9c8f2e12c0eff8964721fe9e403d94967c3a -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_i18n_fields-1.1.0-py3-none-any.whl.
File metadata
- Download URL: django_i18n_fields-1.1.0-py3-none-any.whl
- Upload date:
- Size: 48.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ce42218695573a692103ae048422881076c36c52643f7d2dbc3c891f82c1c33
|
|
| MD5 |
3c798198362f6277b20d446e10144d09
|
|
| BLAKE2b-256 |
9561cab21df6af7fe8ab3ca05afe844c8b1bd4d532d6b5db13c0cb92688ec1eb
|
Provenance
The following attestation bundles were made for django_i18n_fields-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on huynguyengl99/django-i18n-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_i18n_fields-1.1.0-py3-none-any.whl -
Subject digest:
8ce42218695573a692103ae048422881076c36c52643f7d2dbc3c891f82c1c33 - Sigstore transparency entry: 884068977
- Sigstore integration time:
-
Permalink:
huynguyengl99/django-i18n-fields@53ca9c8f2e12c0eff8964721fe9e403d94967c3a -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/huynguyengl99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@53ca9c8f2e12c0eff8964721fe9e403d94967c3a -
Trigger Event:
push
-
Statement type: