{"id":13625791,"url":"https://github.com/MongoEngine/django-mongoengine","last_synced_at":"2025-04-16T10:33:07.930Z","repository":{"id":3292972,"uuid":"4334103","full_name":"MongoEngine/django-mongoengine","owner":"MongoEngine","description":"django mongoengine integration","archived":false,"fork":false,"pushed_at":"2025-03-06T23:05:11.000Z","size":1206,"stargazers_count":751,"open_issues_count":23,"forks_count":203,"subscribers_count":71,"default_branch":"master","last_synced_at":"2025-04-07T22:06:02.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MongoEngine.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-05-15T09:28:40.000Z","updated_at":"2025-03-31T03:46:16.000Z","dependencies_parsed_at":"2025-03-10T18:13:40.083Z","dependency_job_id":"7821d768-bd16-4912-b75d-ab10d30861cd","html_url":"https://github.com/MongoEngine/django-mongoengine","commit_stats":{"total_commits":508,"total_committers":29,"mean_commits":"17.517241379310345","dds":"0.34842519685039375","last_synced_commit":"4984496054ba2b8043d16ce75a6b78ecd27ff908"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MongoEngine%2Fdjango-mongoengine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MongoEngine%2Fdjango-mongoengine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MongoEngine%2Fdjango-mongoengine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MongoEngine%2Fdjango-mongoengine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MongoEngine","download_url":"https://codeload.github.com/MongoEngine/django-mongoengine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249228273,"owners_count":21233852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:02:02.103Z","updated_at":"2025-04-16T10:33:07.924Z","avatar_url":"https://github.com/MongoEngine.png","language":"Python","readme":"==================\nDjango-MongoEngine\n==================\n\n|stand-with-ukraine|\n\n|lifecycle| |gitter|\n\n.. |lifecycle| image:: https://img.shields.io/osslifecycle/MongoEngine/django-mongoengine\n   :alt: OSS Lifecycle\n\n.. |gitter| image:: https://badges.gitter.im/gitterHQ/gitter.png\n   :target: https://gitter.im/MongoEngine/django-mongoengine\n   :alt: Gitter chat\n\n.. |stand-with-ukraine| image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg\n   :target: https://stand-with-ukraine.pp.ua\n   :alt: Stand With Ukraine\n\nTHIS IS UNSTABLE PROJECT, IF YOU WANT TO USE IT - FIX WHAT YOU NEED\n\nRight now we're targeting to get things working on Django 4.2;\n\nWARNING: This project is not in good state, and is likely to break with django updates. Do not use it for any new projects.\n\nRecommended way for new projects is `django-mongodb-backend \u003chttps://github.com/mongodb/django-mongodb-backend\u003e`_.\n\nWorking / Django 4.2\n------------------------\n\n* [ok] sessions\n* [ok] models/fields, fields needs testing\n* [ok] views\n* [ok] auth\n* [?] admin - partially working, some things broken\n\nCurrent status\n-------------------------------------------------------------------------------\n\nMany parts of projects rewritten/removed;\nInstead of copying django code i try to subclass/reuse/even monkey-patch;\nEverything listed above is working; admin - just base fuctions\nlike changelist/edit, not tested with every form type; need's more work.\n\nSome code just plaholder to make things work;\n`django/forms/document_options.py` - dirty hack absolutely required to\nget thigs work with django. It replaces mongo _meta on model/class and\nprovide django-like interface.\nIt get's replaced after class creation via some metaclass magick.\n\nFields notes\n------------\n\n* Project uses mongoengine style argument `required=False`, not django style `blank=False`,\n  to be compatible with mongo-types.\n  **All your fields are optional by default.**\n\n\nTODO\n----\n\n* Sync some files/docs that removed from mongoengine: https://github.com/seglberg/mongoengine/commit/a34f4c1beb93f430c37da20c8fd96ce02a0f20c1?diff=unified\n* Add docs for integrating: https://github.com/hmarr/django-debug-toolbar-mongo\n* Take a look at django-mongotools: https://github.com/wpjunior/django-mongotools\n\nConnecting\n==========\n\nIn your **settings.py** file, add following lines::\n\n    MONGODB_DATABASES = {\n        \"default\": {\n            \"name\": database_name,\n            \"host\": database_host,\n            \"password\": database_password,\n            \"username\": database_user,\n            \"tz_aware\": True, # if you using timezones in django (USE_TZ = True)\n        },\n    }\n\n    INSTALLED_APPS += [\"django_mongoengine\"]\n\nDocuments\n=========\nInhherit your documents from ``django_mongoengine.Document``,\nand define fields using ``django_mongoengine.fields``.::\n\n    from django_mongoengine import Document, EmbeddedDocument, fields\n\n    class Comment(EmbeddedDocument):\n        created_at = fields.DateTimeField(\n            default=datetime.datetime.now, editable=False,\n        )\n        author = fields.StringField(verbose_name=\"Name\", max_length=255)\n        email  = fields.EmailField(verbose_name=\"Email\")\n        body = fields.StringField(verbose_name=\"Comment\")\n\n    class Post(Document):\n        created_at = fields.DateTimeField(\n            default=datetime.datetime.now, editable=False,\n        )\n        title = fields.StringField(max_length=255)\n        slug = fields.StringField(max_length=255, primary_key=True)\n        comments = fields.ListField(\n            fields.EmbeddedDocumentField('Comment'), required=False,\n        )\n\n\nSessions\n========\nDjango allows the use of different backend stores for its sessions. MongoEngine\nprovides a MongoDB-based session backend for Django, which allows you to use\nsessions in your Django application with just MongoDB. To enable the MongoEngine\nsession backend, ensure that your settings module has\n``'django.contrib.sessions.middleware.SessionMiddleware'`` in the\n``MIDDLEWARE_CLASSES`` field  and ``'django.contrib.sessions'`` in your\n``INSTALLED_APPS``. From there, all you need to do is add the following line\ninto your settings module::\n\n    SESSION_ENGINE = 'django_mongoengine.sessions'\n    SESSION_SERIALIZER = 'django_mongoengine.sessions.BSONSerializer'\n\nDjango provides session cookie, which expires after\n```SESSION_COOKIE_AGE``` seconds, but doesn't delete cookie at sessions\nbackend, so ``'mongoengine.django.sessions'`` supports  `mongodb TTL \u003chttp://docs.mongodb.org/manual/tutorial/expire-data/\u003e`_.\n\n.. note:: ``SESSION_SERIALIZER`` is only necessary in Django\u003e1.6 as the default\n   serializer is based around JSON and doesn't know how to convert\n   ``bson.objectid.ObjectId`` instances to strings.\n\n\nHow to run example app\n----------------------\n.. code::\n\n    uv sync --group dev\n    uv pip install -r example/tumblelog/requirements.txt\n    uv run python example/tumblelog/manage.py runserver\n\n\nHow to run tests\n----------------\n.. code::\n\n    uv run python -m pytest\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMongoEngine%2Fdjango-mongoengine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMongoEngine%2Fdjango-mongoengine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMongoEngine%2Fdjango-mongoengine/lists"}