Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Neat ODM wrapper around great PyMongo driver

Project description

Build Status

Documentation: #TODO

Ognom is object-to-document mapper for mongodb. Currently ognom uses pymongo as default backend, but you can easily implement your own backend based on another driver (for example asyncio-mongo) if needed, as serialization and storage logic in ognom are separated.

Supports python2.6+, python3.3+, PyPy.

Documentation: #TODO


pip install ognom




  • Vanilla python, no dependencies;
  • From version 1.0 exposes full pymongo API(!);
  • Easy to write your own backend with your own API.


from ognom.base import (ConnectionManager, Document, Repository,
from ognom.fields import StringField, IntField

    'main': {  # ognom use aliases for databases to make it possible to use multiple db's per project
        'name': 'birzha_main',
        'args': [''],
        'kwargs': {'socketTimeoutMS': 60000}},})

class Foo(Document):
    db_name = 'main'  # db alias
    _collection_name = 'my_foos'  # collection name (by default 'foos')

    meta = {
        'indexes': [
                'index': [('bar', 1), ('baz', -1)],
                'background': True,

    bar = StringField(required=True, default='baaar')
    baz = IntField(choices=[10, 20, 30, 40, 50])

class FooRep(Repository):
    _model_class = Foo

inject_repositories([FooRep])  # weird part, will be removed soon

foo1 = Foo.objects.create({'bar': 'lalala'})
assert Foo.objects.get({'bar': 'lalala'}).id ==

foo2 = Foo(bar='lololo', baz=10)
assert is None
assert is not None

foos = Foo.objects.find({'bar': 'lalala'})  # not list but CursorWrapper!
assert len(list(foos)) == 1

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


This version
History Node


History Node


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
ognom-0.3.1.tar.gz (14.8 kB) Copy SHA256 hash SHA256 Source None Sep 2, 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