On Fri, May 24, 2013 at 1:26 PM, Kurtis <[email protected]> wrote:

> 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?
>

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 %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to