MultiLingualField for MongoEngine
Project description
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)
Built Distribution
File details
Details for the file mongoengine-mls-1.1.0.tar.gz
.
File metadata
- Download URL: mongoengine-mls-1.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 689c8a2a083ed5999faec6829dc2d15f01c0b13e4a71b758cef8d14b641d82dd |
|
MD5 | 9b522b7e89e5dd8ed958b4c8d01f1864 |
|
BLAKE2b-256 | e72ed736e1f38ab7f5448e546ca4b33638705de9c9952a68894cf2522e12f953 |
File details
Details for the file mongoengine_mls-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: mongoengine_mls-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a768967995d36376bbb9103706903642fdf5c06c1e2c1f680243c79b0e2e7d |
|
MD5 | 237ece81f92407b2260cc0501087845d |
|
BLAKE2b-256 | bd5e80350ec0feaa89d7082830ade3b94fd8467b43d827f54af86f0b16858304 |