Skip to main content

Store internationalized strings in Django models

Project description

https://img.shields.io/pypi/v/django-i18nfield.svg https://readthedocs.org/projects/django-i18nfield/badge/?version=latest https://travis-ci.org/raphaelm/django-i18nfield.svg?branch=master https://codecov.io/gh/raphaelm/django-i18nfield/branch/master/graph/badge.svg

This is yet another way to store multi-lingual content in Django. In contrast to other options like django-hvad, django-modeltranslation or django-parler it does not require additonal database tables and you can reconfigure the available languages without any changes to the database schema. 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 violates the 1NF. This makes it harder for non-django based programs to interact directly with your database and 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 the ones that we linked above.

However if those limitations are fine for you, this provides you with a very lightweight, easy to use and flexible solution. This approach has been in use in pretix for quite a while, so it has been tested in production. The package contains not only the model fields, but also form fields and everything you need to get them running.

Features

  • Very easy installation

  • Internationalized versions of CharField and TextField 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 <mail@raphaelmichel.de>. See the AUTHORS file for a list of all the awesome folks who contributed to this project.

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

django_i18nfield-1.10.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

django_i18nfield-1.10.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file django_i18nfield-1.10.2.tar.gz.

File metadata

  • Download URL: django_i18nfield-1.10.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for django_i18nfield-1.10.2.tar.gz
Algorithm Hash digest
SHA256 8b946afa9bb306ca0f01b71b9c8c70b3b2450d66de82d00caea6bd492e27c1f2
MD5 a120a137354c5944e9c3a9817c53688d
BLAKE2b-256 f5edd7ad1d3ae736d4e06ff16a129a9a0d17ca4a37d3362be1bb913467464d55

See more details on using hashes here.

File details

Details for the file django_i18nfield-1.10.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_i18nfield-1.10.2-py3-none-any.whl
Algorithm Hash digest
SHA256 524382b366cdbfc24f47a5b4871a5676e93a5b18a35484b78eb09dd7a6cf1ff6
MD5 02838255f831b4893c805746aa13d54b
BLAKE2b-256 a9124738cea9fc254f6cc52093d4dd27ec98a4abf6bd1866518723d85a81a144

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page