Package: django-mongoengine
THIS IS UNSTABLE PROJECT, IF YOU WANT TO USE IT - FIX WHAT YOU NEEDRight now we’re targeting to get things working on Django 4.2;WARNING: This project is not in good state, and is likely to break with django updates.
It’s better to use raw mongoengine.Working / Django 3.2-4.2[ok] sessions[ok] models/fields, fields needs testing[ok] views[ok] auth[?] admin - partially working, some things brokenCurrent statusMany parts of projects rewritten/removed;
Instead of copying django code i try to subclass/reuse/even monkey-patch;
Everything listed above is working; admin - just base fuctions
like changelist/edit, not tested with every form type; need’s more work.Some code just plaholder to make things work;django/forms/document_options.py- dirty hack absolutely required to
get thigs work with django. It replaces mongo _meta on model/class and
provide django-like interface.
It get’s replaced after class creation via some metaclass magick.Fields notesmongo defaults Field(required=False), changed to django-style defaults
-> Field(blank=False), and setting required = not blank in Field.__init__TODOSync some files/docs that removed from mongoengine:https://github.com/seglberg/mongoengine/commit/a34f4c1beb93f430c37da20c8fd96ce02a0f20c1?diff=unifiedAdd docs for integrating:https://github.com/hmarr/django-debug-toolbar-mongoTake a look at django-mongotools:https://github.com/wpjunior/django-mongotoolsConnectingIn yoursettings.pyfile, add following lines:MONGODB_DATABASES = {
    "default": {
        "name": database_name,
        "host": database_host,
        "password": database_password,
        "username": database_user,
        "tz_aware": True, # if you using timezones in django (USE_TZ = True)
    },
}

INSTALLED_APPS += ["django_mongoengine"]DocumentsInhherit your documents fromdjango_mongoengine.Document,
and define fields usingdjango_mongoengine.fields.:from django_mongoengine import Document, EmbeddedDocument, fields

class Comment(EmbeddedDocument):
    created_at = fields.DateTimeField(
        default=datetime.datetime.now, editable=False,
    )
    author = fields.StringField(verbose_name="Name", max_length=255)
    email  = fields.EmailField(verbose_name="Email")
    body = fields.StringField(verbose_name="Comment")

class Post(Document):
    created_at = fields.DateTimeField(
        default=datetime.datetime.now, editable=False,
    )
    title = fields.StringField(max_length=255)
    slug = fields.StringField(max_length=255, primary_key=True)
    comments = fields.ListField(
        fields.EmbeddedDocumentField('Comment'), blank=True,
    )SessionsDjango allows the use of different backend stores for its sessions. MongoEngine
provides a MongoDB-based session backend for Django, which allows you to use
sessions in your Django application with just MongoDB. To enable the MongoEngine
session backend, ensure that your settings module has'django.contrib.sessions.middleware.SessionMiddleware'in theMIDDLEWARE_CLASSESfield  and'django.contrib.sessions'in yourINSTALLED_APPS. From there, all you need to do is add the following line
into your settings module:SESSION_ENGINE = 'django_mongoengine.sessions'
SESSION_SERIALIZER = 'django_mongoengine.sessions.BSONSerializer'Django provides session cookie, which expires after`SESSION_COOKIE_AGE`seconds, but doesn’t delete cookie at sessions
backend, so'mongoengine.django.sessions'supportsmongodb TTL.NoteSESSION_SERIALIZERis only necessary in Django>1.6 as the default
serializer is based around JSON and doesn’t know how to convertbson.objectid.ObjectIdinstances to strings.How to run example apppoetry install
poetry run pip install -r example/tumblelog/requirements.txt
poetry run python example/tumblelog/manage.py runserverHow to run testspoetry install
poetry run python -m pytest