Skip to main content

MultiLingualField for MongoEngine

Project description

https://travis-ci.org/rembish/mongoengine-mls.svg?branch=master https://coveralls.io/repos/rembish/mongoengine-mls/badge.svg https://pypip.in/download/mongoengine-mls/badge.svg https://pypip.in/version/mongoengine-mls/badge.svg https://pypip.in/py_versions/mongoengine-mls/badge.svg https://pypip.in/implementation/mongoengine-mls/badge.svg https://pypip.in/status/mongoengine-mls/badge.svg https://pypip.in/wheel/mongoengine-mls/badge.svg https://pypip.in/egg/mongoengine-mls/badge.svg https://pypip.in/format/mongoengine-mls/badge.svg https://pypip.in/license/mongoengine-mls/badge.svg

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'>

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

mongoengine-mls-1.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

mongoengine_mls-1.1.0-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mongoengine-mls-1.1.0.tar.gz.

File metadata

File hashes

Hashes for mongoengine-mls-1.1.0.tar.gz
Algorithm Hash digest
SHA256 689c8a2a083ed5999faec6829dc2d15f01c0b13e4a71b758cef8d14b641d82dd
MD5 9b522b7e89e5dd8ed958b4c8d01f1864
BLAKE2b-256 e72ed736e1f38ab7f5448e546ca4b33638705de9c9952a68894cf2522e12f953

See more details on using hashes here.

File details

Details for the file mongoengine_mls-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mongoengine_mls-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d1a768967995d36376bbb9103706903642fdf5c06c1e2c1f680243c79b0e2e7d
MD5 237ece81f92407b2260cc0501087845d
BLAKE2b-256 bd5e80350ec0feaa89d7082830ade3b94fd8467b43d827f54af86f0b16858304

See more details on using hashes here.

Supported by

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