5

This question is already asked on StackOverflow,

The asked questions date back to 2013, Its 2015 now and Django has grown up fast.

What is the situation of using mongodb with Django 1.8 as of 2015?

Does Django support Monogodb out of the box (with db adapters)? or another distribution like django-nonrel should be used?

5 Answers5

3

I don't think Django provides out of the box support for MongoDB. It is more tailored for relational databases.

One solution could be using MongoEngine.

MongoEngine is an Object-Document Mapper, written in Python for working with MongoDB.

You need to just configure MongoEngine with Django and then it should work comfortably.

Rahul Gupta
  • 46,769
  • 10
  • 112
  • 126
  • `MongoEngine` seems to require Django 1.6-nonrel, which is a downgrade and lacks official support – Peter G. Nov 26 '15 at 15:54
  • No, Mongoengine does not require Django-nonrel to work along with it. You can install Django, Mongoengine and pymongo and it should work for you. I am currently using Django (1.8.2), mongoengine (0.10.0) with pymongo (3.0.3) in a project and its working perfectly. – Rahul Gupta Nov 26 '15 at 17:05
  • @PeterGerhat seems to have been referring to django-mongodb-engine which does require nonrel req. an older version of [django] (https://django-mongodb-engine.readthedocs.org/en/latest/topics/setup.html#django-nonrel).. Looking at the two on github, seems MongoEngine would be the way to go.. – codervince Mar 01 '16 at 11:35
  • That said, MongoEngine is looking for hired hands to get its legacy [django plugin up to scratch](http://mongoengine-odm.readthedocs.org/django.html) so perhaps I spoke too soon. – codervince Mar 01 '16 at 11:41
2

just my thoughts and somewhat subjective and opinionated but I would say it does not work very well. I quickly disbanded the idea of trying to run Django with MongoDB, since it's auth system is heavily reliant upon a relational database to work.

There are apparently ways around this, but ultimately I decided for my project it was not worth the effort just to use MongoDB.

Chris Hawkes
  • 11,923
  • 6
  • 58
  • 68
2

Does Django support Monogodb out of the box (with db adapters)?

No, it does not. If you can find a django compatible engine for mongodb, then it will work perfectly.

The good news is there is such an engine, called django-mongodb-engine; the bad news is that it relies on django-nonrel which is not updated against the latest stable version of django.

So, if you must - you can use MongoDB at the expense of not having some updated django features available to you (and more importantly, any security patches).

If you want to supplement your main database with mongodb - that is, mongodb will not be your primary database, then the process is a lot easier.

So, in summary:

  • django 1.8 provides no out-of-the-box support for mongodb (or other non-relational databases) as the primary data store.

  • support is available using the third party django-nonrel package, which is behind the current django production version.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
2

I came across a new package that does support the latest django on MongoDB: djongo

As stated above, mongoengine does not support all contrib apps of django. Especially the auth app doesn' work on mongoengine

Djongo claims to compile SQL queries into mongodb queries. So its is essentially version agnostic and works for all versions of Django.

Disclosure: I have contributed to this package by making minor bug fixes.

nesdis
  • 1,182
  • 13
  • 16
1

I know that its been three years but for those who are wondering about MongoDB and Django now should know that the situation has not changed. Mongoengine as described earlier is a good enough tool but still there are limitations. For instance when i integrated mongodb with django using mongoengine i was not able the use elastic search with my application. Furthermore with mongoDB you loose you loose Django admin and authentications functionalities. So, MongoDB with Django is still a risky choice

saim2025
  • 280
  • 2
  • 5
  • 14