Django 1.8 and MongoDB?
Asked Answered
L

5

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?

Lefevre answered 27/8, 2015 at 17:46 Comment(0)
A
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.

Accelerant answered 27/8, 2015 at 18:55 Comment(4)
MongoEngine seems to require Django 1.6-nonrel, which is a downgrade and lacks official supportImprovisator
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.Accelerant
@PeterGerhat seems to have been referring to django-mongodb-engine which does require nonrel req. an older version of [django] (django-mongodb-engine.readthedocs.org/en/latest/topics/…).. Looking at the two on github, seems MongoEngine would be the way to go..Xylia
That said, MongoEngine is looking for hired hands to get its legacy django plugin up to scratch so perhaps I spoke too soon.Xylia
P
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.

Polar answered 27/8, 2015 at 18:23 Comment(0)
V
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.

Version answered 27/8, 2015 at 19:3 Comment(0)
E
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.

Eckstein answered 15/8, 2017 at 11:0 Comment(0)
M
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

Mainis answered 7/7, 2018 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.