mongoengine 0.29.3


pip install mongoengine

  Latest version

Released: Mar 10, 2026

Project Links

Meta
Author: Harry Marr
Maintainer: Bastien Gerard
Requires Python: >=3.7

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

Topic
  • Database
  • Software Development :: Libraries :: Python Modules
Info:

MongoEngine is an ORM-like layer on top of PyMongo.

Repository:

https://github.com/MongoEngine/mongoengine

Author:

Harry Marr (http://github.com/hmarr)

Maintainer:

Bastien Gerard (http://github.com/bagerard)

https://travis-ci.org/MongoEngine/mongoengine.svg?branch=master https://coveralls.io/repos/github/MongoEngine/mongoengine/badge.svg?branch=master https://img.shields.io/badge/code%20style-black-000000.svg https://pepy.tech/badge/mongoengine/month https://img.shields.io/pypi/v/mongoengine.svg https://readthedocs.org/projects/mongoengine-odm/badge/?version=latest

About

MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation is available at https://mongoengine-odm.readthedocs.io - there is currently a tutorial, a user guide, and an API reference.

Supported MongoDB Versions

MongoEngine is currently tested against MongoDB v4.4, v5.0, v6.0 and v7.0. Future versions should be supported as well, but aren’t actively tested at the moment. Make sure to open an issue or submit a pull request if you experience any problems with a more recent MongoDB versions.

Installation

We recommend the use of virtualenv and of pip. You can then use python -m pip install -U mongoengine. You may also have setuptools and thus you can use easy_install -U mongoengine. Another option is pipenv. You can then use pipenv install mongoengine to both create the virtual environment and install the package. Otherwise, you can download the source from GitHub and run python setup.py install.

The support for Python2 was dropped with MongoEngine 0.20.0

Dependencies

All of the dependencies can easily be installed via python -m pip. At the very least, you’ll need these two packages to use MongoEngine:

  • pymongo>=3.4

If you utilize a DateTimeField, you might also use a more flexible date parser:

  • dateutil>=2.1.0

If you need to use an ImageField or ImageGridFsProxy:

  • Pillow>=7.0.0

If you need to use signals:

  • blinker>=1.3

Examples

Some simple examples of what MongoEngine code looks like:

from mongoengine import *
connect('mydb')

class BlogPost(Document):
    title = StringField(required=True, max_length=200)
    posted = DateTimeField(default=datetime.datetime.utcnow)
    tags = ListField(StringField(max_length=50))
    meta = {'allow_inheritance': True}

class TextPost(BlogPost):
    content = StringField(required=True)

class LinkPost(BlogPost):
    url = StringField(required=True)

# Create a text-based post
>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')
>>> post1.tags = ['mongodb', 'mongoengine']
>>> post1.save()

# Create a link-based post
>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')
>>> post2.tags = ['mongoengine', 'documentation']
>>> post2.save()

# Iterate over all posts using the BlogPost superclass
>>> for post in BlogPost.objects:
...     print('===', post.title, '===')
...     if isinstance(post, TextPost):
...         print(post.content)
...     elif isinstance(post, LinkPost):
...         print('Link:', post.url)
...

# Count all blog posts and its subtypes
>>> BlogPost.objects.count()
2
>>> TextPost.objects.count()
1
>>> LinkPost.objects.count()
1

# Count tagged posts
>>> BlogPost.objects(tags='mongoengine').count()
2
>>> BlogPost.objects(tags='mongodb').count()
1

Tests

To run the test suite, ensure you are running a local instance of MongoDB on the standard port and have pytest installed. Then, run pytest tests/.

To run the test suite on every supported Python and PyMongo version, you can use tox. You’ll need to make sure you have each supported Python version installed in your environment and then:

# Install tox
$ python -m pip install tox
# Run the test suites
$ tox

Community

Contributing

We welcome contributions! See the Contribution guidelines

0.29.3 Mar 10, 2026
0.29.2 Mar 10, 2026
0.29.1 Sep 19, 2024
0.29.0 Aug 26, 2024
0.28.2 Mar 07, 2024
0.28.1 Mar 04, 2024
0.28.0 Mar 02, 2024
0.27.0 Mar 03, 2023
0.26.0 Jan 20, 2023
0.25.0 Dec 28, 2022
0.24.2 Jul 17, 2022
0.24.1 Mar 21, 2022
0.24.0 Feb 20, 2022
0.23.1 May 04, 2021
0.23.0 Mar 04, 2021
0.22.1 Dec 16, 2020
0.22.0 Dec 14, 2020
0.21.0 Nov 19, 2020
0.20.0 May 02, 2020
0.19.1 Jan 04, 2020
0.19.0 Dec 24, 2019
0.18.2 Jun 25, 2019
0.18.0 Jun 12, 2019
0.17.0 Mar 11, 2019
0.16.3 Dec 06, 2018
0.16.2 Nov 21, 2018
0.16.1 Nov 14, 2018
0.16.0 Nov 05, 2018
0.15.3 Jul 16, 2018
0.15.0 Nov 06, 2017
0.14.3 Oct 01, 2017
0.13.0 Apr 16, 2017
0.12.0 Apr 07, 2017
0.11.0 Dec 13, 2016
0.10.9 Dec 11, 2016
0.10.7 Nov 29, 2016
0.10.6 Jan 25, 2016
0.10.5 Nov 30, 2015
0.10.4 Nov 30, 2015
0.10.1 Nov 18, 2015
0.10.0 Jun 24, 2015
0.9.0 Mar 28, 2015
0.8.8 Apr 08, 2015
0.8.7.1 Apr 08, 2015
0.8.7.post2 Apr 08, 2015
0.8.7 Apr 08, 2015
0.8.6 Dec 04, 2013
0.8.5 Dec 04, 2013
0.8.4 Aug 23, 2013
0.8.3 Aug 23, 2013
0.8.2 Aug 23, 2013
0.8.1 Aug 23, 2013
0.8.0 Aug 23, 2013
0.7.10 Aug 23, 2013
0.7.9 Aug 23, 2013
0.7.8 Aug 23, 2013
0.7.5 Aug 23, 2013
0.7.4 Aug 23, 2013
0.7.3 Aug 23, 2013
0.7.2 Aug 23, 2013
0.7.1 Aug 23, 2013
0.7.0 Aug 23, 2013
0.6.20 Aug 23, 2013
0.6.19 Aug 23, 2013
0.6.17 Aug 23, 2013
0.6.16 Aug 23, 2013
0.6.15 Aug 23, 2013
0.6.13 Aug 23, 2013
0.6.12 Aug 23, 2013
0.6.10 Aug 23, 2013
0.6.8 Aug 23, 2013
0.6.7 Aug 23, 2013
0.6.6 Aug 23, 2013
0.6.4 Aug 23, 2013
0.6.3 Aug 23, 2013
0.6.1 Aug 23, 2013
0.5.2 Aug 23, 2013
0.5.1 Aug 23, 2013
0.5 Aug 23, 2013
0.4 Aug 23, 2013

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
pymongo (<5.0,>=3.4)