58
As Mike says, you can’t avoid PyMongo – all the other interfaces build on top of it. These other interfaces are arguably unnecessary. ORMs such as that used in Django are useful when dealing with SQL because they mitigate the complexity of creating SQL queries and schemas, and parsing result sets into objects.
PyMongo however already has that covered – queries go through a convenient and simple API and results coming from MongoDB already are objects (well, dicts in Python – same difference) by definition. If you feel that you really need to decorate your Mongo documents with Python objects, it’s easy to add a SON manipulator to PyMongo. The nice thing about this approach is that you can write code directly on PyMongo, and slide in additional functionality later on without having to insert a new API between your code and PyMongo.
What’s left? Schema creation and migration are somewhat useful, but are almost as simply done ad-hoc – chances are if you’re considering using MongoDB you want to break out of the traditional SQL-style model anyway. Also, if there were a fully Django-compatible MongoDB ORM you might get some mileage out of it. Anything less than that and you will probably be creating work for yourself.
You won’t regret using PyMongo directly.
One last option worth watching if you are interested in top efficiency is the asynchronous version of PyMongo, here: http://github.com/fiorix/mongo-async-python-driver
11
I’ve been working with Mongokit. Like it so far.
Here’s a blog post I referenced when integrating with Django
- [Django]-Where are the Assertion Methods list from Django TestCase?
- [Django]-Django Count() in multiple annotations
- [Django]-How to select a record and update it, with a single queryset in Django?
6
Both MongoEngine and Ming depend on PyMongo – they just put some nice functionality on top of it. I’d recommend at least starting w/ PyMongo directly – that way if you decide to use one of the other tools and run into issues it will be easy to understand what is going on “under the hood”. That said, I’m highly biased ;).
- [Django]-How can I allow django admin to set a field to NULL?
- [Django]-Getting the SQL from a Django QuerySet
- [Django]-How do I import the Django DoesNotExist exception?
5
You might give django-mongodb-engine a try. It’s a backend for Django-nonrel, so you can continue to use Django’s models and ORM. It’s not yet as complete as the other APIs, though:
http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-released
- [Django]-Why does django run everything twice?
- [Django]-Django: return string from view
- [Django]-Django get list of models in application
2
I just found ‘micromongo’:
http://packages.python.org/micromongo/
Looks like it adds just enough useful stuff on top of pymongo without getting in the way.
- [Django]-Setting Django up to use MySQL
- [Django]-CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true
- [Django]-How to get primary keys of objects created using django bulk_create
0
The official Mongodb documentation talks about djongo. It works by translating SQL queries into mongodb queries.
You don’t need django-nonrel to run it.
All native Django contrib modules (eg. admin, user, session) work without any modification.
MongoEngine requires rewriting contrib modules and last I checked, the native admin module didn’t run on MongoEngine.
Your existing models run without any ORM translation as well.
- [Django]-Generate unique id in django from a model field
- [Django]-Gunicorn + nginx: Server via socket or proxy?
- [Django]-SyntaxError: Generator expression must be parenthesized