django-dynamic-translations
Model-specific translations for Django without a shared generic translation table.
The package generates a <Model>Translation model from each TranslatedField, exposes
the translated values as natural model attributes, and integrates all configured
languages into a single Django form or admin page.
The project is currently in alpha. Its public API is usable, but may still evolve before version 1.0.
Installation
Install the package:
pip install django-dynamic-translations
Then add it to INSTALLED_APPS and configure only the languages supported by the
application:
INSTALLED_APPS = [
# ...
"django_dynamic_translations",
]
LANGUAGE_CODE = "en-us"
LANGUAGES = [
("en-us", "English (United States)"),
("it", "Italiano"),
]
Only put application-supported languages in LANGUAGES: each language becomes a
section in the generated form.
Model
from django.db import models
from django_dynamic_translations.models import TranslatableModel, TranslatedField
class Trip(TranslatableModel):
name = TranslatedField[str](models.CharField(max_length=255))
slug = TranslatedField[str](models.SlugField(max_length=255))
description = TranslatedField[str](models.TextField())
Run makemigrations normally. Django creates both Trip and TripTranslation.
The default-language translation is required. Other languages fall back to it when
read through trip.name, trip.slug, or the other aliases.
Use prefetch_translations() for lists and paginated querysets:
trips = Trip.objects.order_by("pk").prefetch_translations()
Forms and admin
from django.contrib import admin
from django_dynamic_translations.admin import TranslatableAdmin
from django_dynamic_translations.forms import TranslatableModelForm
from .models import Trip
class TripForm(TranslatableModelForm):
class Meta:
model = Trip
fields = ()
@admin.register(Trip)
class TripAdmin(TranslatableAdmin):
form = TripForm
list_display = ("name", "slug")
search_fields = ("translations__name", "translations__slug")
For generated forms without a custom subclass, use
translatable_modelform_factory(Trip).
The form displays all translated fields for all configured languages. The default language is mandatory. An optional language is saved only when it is complete; clearing every field removes that translation.
Development
The project uses uv:
uv sync
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest
Releases
GitHub releases publish the matching wheel and source distribution to PyPI through
Trusted Publishing. The Git tag must match the package version, for example v0.1.0.
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_dynamic_translations-0.1.0.tar.gz.
File metadata
- Download URL: django_dynamic_translations-0.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35be5757cb3ecfbe011cfcf89b8b9122c87c05dd66c0409f6226a51923369d16
|
|
| MD5 |
55271929cb6d1feeda9d4438cd4618c5
|
|
| BLAKE2b-256 |
d6d02e15f55d1645f83538a4d084efe018c7b8ceda252a411a597257fa5f4352
|
Provenance
The following attestation bundles were made for django_dynamic_translations-0.1.0.tar.gz:
Publisher:
publish.yml on AndreaBellomia/django-dynamic-translations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_dynamic_translations-0.1.0.tar.gz -
Subject digest:
35be5757cb3ecfbe011cfcf89b8b9122c87c05dd66c0409f6226a51923369d16 - Sigstore transparency entry: 2508328626
- Sigstore integration time:
-
Permalink:
AndreaBellomia/django-dynamic-translations@1674d7c8ff2c7fa1d4c143387ffdbe510d7ad324 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AndreaBellomia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1674d7c8ff2c7fa1d4c143387ffdbe510d7ad324 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_dynamic_translations-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_dynamic_translations-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13d4cc859ac699f86540a961bfd67b5ba76f3dac0b50588449d17ff30c732e96
|
|
| MD5 |
c83509f925597defe6e6aeefa25a6c49
|
|
| BLAKE2b-256 |
f96b3196a090aaa3b4c01e046f820c3f47729c64f7db59bb69912bb1865a4324
|
Provenance
The following attestation bundles were made for django_dynamic_translations-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on AndreaBellomia/django-dynamic-translations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_dynamic_translations-0.1.0-py3-none-any.whl -
Subject digest:
13d4cc859ac699f86540a961bfd67b5ba76f3dac0b50588449d17ff30c732e96 - Sigstore transparency entry: 2508328911
- Sigstore integration time:
-
Permalink:
AndreaBellomia/django-dynamic-translations@1674d7c8ff2c7fa1d4c143387ffdbe510d7ad324 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/AndreaBellomia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1674d7c8ff2c7fa1d4c143387ffdbe510d7ad324 -
Trigger Event:
release
-
Statement type: