I18nFields for Django
This is yet another way to store multi-lingual content in Django. In contrast to other optionslike django-hvad, django-modeltranslation or django-parler it does not require additonaldatabase tables and you can reconfigure the available languages without any changes to the databaseschema. In constrast to nece, it is not specific to PostgreSQL.
How does it work then? It stores JSON data into a TextField
. Yes, this is kinda dirty and violatesthe 1NF. This makes it harder for non-django based programs to interact directly with your databaseand is not perfectly efficient in terms of storage space.It also lacks the ability to do useful lookups, searches and indices on internationalized fields.If one of those things are important to you, this project is not for you, please choose one of theones that we linked above.
However if those limitations are fine for you, this provides you with a very lightweight, easy to use andflexible solution. This approach has been in use in pretix for quite a while, so it has been tested inproduction. The package contains not only the model fields, but also form fields and everything you needto get them running.
Features
- Very easy installation
- Internationalized versions of
CharField
andTextField
types - Integrated form fields types and widgets
- Automatic migration from non-localized fields with a simple migration
- Full support for forms and formsets
- Possibility to dynamically limit the displayed languages
- Very basic integration with django admin
- Integration with Django Restframework
- Comprehensive test suite and production-tested
Tested with:
- Python 3.6 to 3.10
- Django 3.2 to 4.0
License
The code in this repository is published under the terms of the Apache License.See the LICENSE file for the complete license text.
This project is maintained by Raphael Michel <[email protected]>. See theAUTHORS file for a list of all the awesome folks who contributed to this project.