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-havd, 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

  • Comprehensive test suite and production-tested

Tested with:

  • Python 3.4 to 3.6

  • Django 1.9 to 1.11

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.0.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_i18nfield-1.0.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file django-i18nfield-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django-i18nfield-1.0.1.tar.gz
Algorithm Hash digest
SHA256 80118ff7ab28ed2c92ad180cd89cbe9a24ab9a14395d2d68af7be57aa69679e2
MD5 ce44538c6fd72d8daf58c986ec39b09f
BLAKE2b-256 95a840e76b5118cde55cf58cfcd94c28c4df3430e20d826e6e8aa90cb5274a23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_i18nfield-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d168ff2bf793590c28e5284630d98c95a892f9dca796200aeb28bf58c5c3c7
MD5 03e0ce559cca010f03dc1f0c591b7a5c
BLAKE2b-256 bad9953574c640e51478bb32662cc5aa408f468524bb8246aadd81a577e80e0b

See more details on using hashes here.

Supported by

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