Skip to main content

MultiLingualField for MongoEngine

Project description

https://travis-ci.org/rembish/mongoengine-mls.svg?branch=master

Simple extension for MongoEngine, which adds MultiLingualField (based on MultiLingualString). Some self-describing examples:

from locale import setlocale, LC_ALL
from mongoengine import Document, connect
from mongoengine_mls import MultiLingualField

class Country(Document):
    meta = {"indexes": ["name.language"]}
    name = MultiLingualField(required=True)

setlocale(LC_ALL, "en_US.UTF-8")
connect("test")

ru = Country(name={"en": "Russia", "ru": u"Россия"})
ru.save()

print(ru.name)  # => Russia
print(ru.name >> "ru")  # => Россия

ru2 = Country.objects.first()
ru2.name = [
    {"language": "en", "value": "Russian Federation"},
    {"language": "ru", "value": u"Российская Федерация"}
]
ru2.save()

print(ru2.name)  # => Russia Federation
print(type(ru2.name))  # => <class 'mls.MultiLingualString'>

Release history Release notifications

This version
History Node

1.1.0

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
mongoengine_mls-1.1.0-py2.py3-none-any.whl (5.0 kB) Copy SHA256 hash SHA256 Wheel 2.7 Apr 17, 2015
mongoengine-mls-1.1.0.tar.gz (3.2 kB) Copy SHA256 hash SHA256 Source None Apr 17, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page