Skip to main content

Latest version Build status pre-commit.ci status Documentation Coverage

μMongo is a Python MongoDB ODM. Its inception comes from two needs: the lack of async ODM and the difficulty to do document (un)serialization with existing ODMs.

From this point, μMongo made a few design choices:

  • Stay close to the standards MongoDB driver to keep the same API when possible: use find({"field": "value"}) like usual but retrieve your data nicely OO wrapped !

  • Work with multiple drivers (PyMongo, TxMongo, motor_asyncio and mongomock for the moment)

  • Tight integration with Marshmallow serialization library to easily dump and load your data with the outside world

  • i18n integration to localize validation error messages

  • Free software: MIT license

  • Test with 90%+ coverage ;-)

Quick example

import datetime as dt
from pymongo import MongoClient
from umongo import Document, fields, validate
from umongo.frameworks import PyMongoInstance

db = MongoClient().test
instance = PyMongoInstance(db)


@instance.register
class User(Document):
    email = fields.EmailField(required=True, unique=True)
    birthday = fields.DateTimeField(
        validate=validate.Range(min=dt.datetime(1900, 1, 1))
    )
    friends = fields.ListField(fields.ReferenceField("User"))

    class Meta:
        collection_name = "user"


# Make sure that unique indexes are created
User.ensure_indexes()

goku = User(email="goku@sayen.com", birthday=dt.datetime(1984, 11, 20))
goku.commit()
vegeta = User(email="vegeta@over9000.com", friends=[goku])
vegeta.commit()

vegeta.friends
# <object umongo.data_objects.List([<object umongo.dal.pymongo.PyMongoReference(document=User, pk=ObjectId('5717568613adf27be6363f78'))>])>
vegeta.dump()
# {id': '570ddb311d41c89cabceeddc', 'email': 'vegeta@over9000.com', friends': ['570ddb2a1d41c89cabceeddb']}
User.find_one({"email": "goku@sayen.com"})
# <object Document __main__.User({'id': ObjectId('570ddb2a1d41c89cabceeddb'), 'friends': <object umongo.data_objects.List([])>,
#                                 'email': 'goku@sayen.com', 'birthday': datetime.datetime(1984, 11, 20, 0, 0)})>

Get it now:

$ pip install umongo           # This installs umongo with pymongo
$ pip install my-mongo-driver  # Other MongoDB drivers must be installed manually

Or to get it along with the MongoDB driver you’re planing to use:

$ pip install umongo[motor]
$ pip install umongo[txmongo]
$ pip install umongo[mongomock]

Support umongo

If you’d like to support the future of the project, please consider contributing to Marshmallow’s Open Collective:

Donate to our collective

Release files for umongo 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for umongo 4.0.0
File Size Uploaded
umongo-4.0.0.tar.gz 175.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for umongo 4.0.0
File Interpreter ABI Platform
umongo-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 220.7 kB

Release files / umongo-4.0.0.tar.gz

Download URL umongo-4.0.0.tar.gz
Size 175.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6c9e9d0795924397658f5b013cb0bac96b8e2f562358e40ba10de1143bbe79be
BLAKE2b-256 checksum
How to use checksums
e6afe012442938077251dda607f4653c4999a9aeb1bcd43889127b23e3d0135e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release files / umongo-4.0.0-py3-none-any.whl

Download URL umongo-4.0.0-py3-none-any.whl
Size 45.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34a1ea6ef90fc669d3db657cfd43772da1e7c28539424e250b637d5c734fda4b
BLAKE2b-256 checksum
How to use checksums
aa87e1723a240bc5785abb25bbd2ec3096710bdd98197b0f29243af7d2d0db94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.15.0

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.6

2 release files

0.7.5

1 release file

0.7.4

2 release files

0.7.3

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page