Django 1.8 and MongoDB?

只愿长相守 提交于 2019-12-07 09:11:43

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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



来源:https://stackoverflow.com/questions/32256173/django-1-8-and-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!