Integrating NoSQL-persisted custom Models

42 views
Skip to first unread message

Kurtis

unread,
May 24, 2013, 1:26:46 AM5/24/13
to django...@googlegroups.com
A project I am working on uses a hybrid SQL/NoSQL data backend.

I'd like to build custom Models which "behave" exactly like the traditional Django Models but are tied into my MongoDB backend.

Where should I start to make sure I cover all bases? Implementing  my own instance Model? I imagine I'll also need custom Model Managers as well.

I'm guessing there are some problems with this approach since they forked Django for a full non-relational release several versions ago. I imagine 3rd party components may also throw their own set of problems at me as well.

If anyone has given this a shot before, can you share some tips or pitfalls you ran into during the process? 

Thanks!
- Kurtis

Russell Keith-Magee

unread,
May 24, 2013, 2:22:45 AM5/24/13
to django...@googlegroups.com
It depends entirely on how "Django-like" you need your models to be.

If you're expecting to be able to just drop a MongoDB store into your project and have any arbitrary Django app run with it -- that's going to cause problems. There are fundamental differences between SQL databases and MongoDB, and it's not possible to abstract away those differences. In particular, deep joins are very difficult/inefficient to implement on Mongo, because Mongo hasn't been optimised for that lookup mode.

However, if you're just looking to be able to do some light introspection -- say, enough to use ModelForms, and maybe some light local attribute querying -- then you should be able to duck type the Django model Meta object and the model manager sufficiently to make simple operations work. I'm not aware of anyone that has tried to do this, however, and the Meta object in particular isn't currently a documented interface, so you're going to need to get to know Django's internals in order to take this approach.

Is there anything you can use out of the box? You might get some traction using django-nonrel, but I can't comment on how well it works. It's a fork of Django 1.3 IIRC, so it's getting quite old in terms of feature set. 

There's also an old GSoC branch that introduced a MongoDB backend; however, that effort stalled due to some complications with automated primary keys and a few other areas. You might be able to resurrect some code from this branch, but again -- it's somewhat stale, and not especially well documented.

Yours,
Russ Magee %-)

Alir3z4

unread,
May 24, 2013, 8:39:59 AM5/24/13
to django...@googlegroups.com
On Friday, May 24, 2013 10:22:45 AM UTC+4, Russell Keith-Magee wrote:
> You might get some traction using django-nonrel, but I can't comment on how well it works. It's a fork of Django 1.3 ...,

I have an app up & running with django-nonrel 1.5, it's in beta but works perfectly with no problem, also mongodb-engine 1.5 beta is also available that can be used to support MongoDB database backend.

for getting django 1.5 you just need 3 things.

* [django-nonrel-1.5-beta][1]
* [django-mongodb-engine-1.5-beta][2]
* [djangotoolbox-1.5-beta][3]

They're all in beta but really works with no issue.

I really looking forward to see NoSQL support in django core, That would be awesome for such an awesome web framework. 

Reply all
Reply to author
Forward
0 new messages