Django-nonrel vs Django-mongodb vs Mongokit vs pymongo native - django

Working on a Django project that requires a NoSQL store and I believe I've settled on Mongo. I've seen a lot of topics that talk about Mongo and Django, but none that mentioned Django-nonrel, and I can't see why it might have been disqualified, but I have no experience with any of them.
Ideally, I'd like to preserve the SQL store for the simple things, user auth, groups, etc., and use Mongo for the bigger data.
I'd also like to have my Mongo-stored objects as classes, in a Django-ORM style, so that I can have a similar 'feel', but that isn't critical.
Lastly, do any of the above allow me to use Django's multi-database support for anything, or are all my mongo queries effectively 'out of band' from the Django ORM?
If there are any other factors I'm missing that might be important, feel free to clue me in. I know little in this arena.

Django-nonrel is the way to go for Django on MongoDB. There's django-mongodb.org, but that's just built on top of Django-nonrel. There's quite a bit of mongodb activity going on the django-nonrel mailing list.
Storing your mongo classes as Django ORM objects works fine, that's the whole point.
I haven't tried using the multi-database support along with SQL. I haven't seen many people use it like that, and I suspect it most likely does not work. There's some work on moving django-nonrel to be officially part of Django 1.4, I suspect it'll work after that's complete.
Using django-nonrel for auth works ok. The main problem is many-to-many relations. The auth module uses that for per user object permissions - that doesn't work. If you don't need that, you could probably get away without using the SQL at all.

Adding onto dragonx answer. The issue with django-nonrel is that the auth module doesn't work.
You can perform many-to-mamy joins using $lookup operator. djongo does automatically for you. It translates SQL syntax into mongodb aggregation queries and populates the object model, like other SQL drivers.
The auth module works fine on djongo

Related

Hooking Django (DRF) to an existing database

I think I am looking for as much advise as possible.
I have a project that I have inherited. The codebase is absolutely awful. I have a Django project, within this a React app. There's all manner of proxies between to fetch from the API to deliver up content.
However, I want to start to re-write the API, as it is awfully put together. Zero documentation.
To re-write the API, I would like take a copy of the exisiting database - and then work with this to write a more consistent API.
What would be your advise/steps/method to achieve this, and what should I look out for when doing this?
N.B. The database is PostgreSQL.
For this Django itself has the inspectdb command.
It will inspect all tables, fields, and foreign-key relations and then create unmanaged models for you. You can fix them manually with (perhaps) missing foreign-keys and then use them in django-rest-framework.

How to setup rethinkdb with django?

I have followed various posts and tutorials but couldn't find anything that is relevant. I found a ORM for rethinkdb "https://github.com/dparlevliet/rwrapper" but don't know how to use it?
I am new to to django and python.
It depends on what you want to do.
There is no way to simple replacement of Django's ORM with RethinkDB now. However, working with RethinkDB driver is simple enough, and similar to how you would use Django ORM.
The nearest thing is indeed rwrapper, you can try starting with this tutorial.
If you don't need to use Model classes, then you just need to find a place to connect to database (or use some sort of Singleton or Factory to connect to the database), and then just import rethinkdb as r and r.connect() and then just write queries with ReQL.
If you need realtime data, then Django is not suitable for that at all. You can consider mixing Django with Tornado
Django doesn't support RethinkDB at the moment and I don't think there's any plan for it as well.
Django developers don't add new stuff to the code base just because it's something new and might be cool. It should be really well mature and a high needs for it. So, I don't think you'll be hearing anything about RethinkDB from Django devs anytime soon.
This project might be something interesting:
https://github.com/thejsj/django-and-rethinkdb
In order to use any database with Django, the adapter should completely be a Django DB Backend in order to work with:
Models
Admin
Forms
Various Class Based Forms
Session
Auth
etc...
In others words, as long as the db backend doesn't support all the django database operations is not something that you wanna use.

What functionality is lost when using django with mongodb?

I am evaluating whether I want to use mongoDB with django for my next project. What I am not sure about, though, is what functionality (ORM, admin, forms, etc.) I loose when I use a DB backend that is not officially supported.
I consider using the mongodb-engine.
So, you have Django-mongoadmin and Django-mongonaut for django-admin stuff. Also
Django-mongodbforms for model forms. MongoEngine as ORM. But this modules are pretty raw and unstable so use it with wariness.

mongodb for django

I like mongodb and django,and there are some frameworks to select:
mongodbengine
django-mongodb-engine
Mongodbengine has good performance and django ORM like api,but when serialize ,it's not supported now.
Django-mongodb-engine is a django backend,you can use it with django ORM.
So django-mongodb-engine is better? and how about its performance?
There are a number of projects out there for incorporating MongoDB with Django but the best one (I believe) is yet to come. Alex Gaynor's Google Summer of Code project is working on a queryset refactor of the Django ORM to allow for non-relational backends. In his last update he stated that they have a working MongoDB backend:
Since this is about the halfway point
of GSOC I'll give a general overview:
we have a working MongoDB backend,
with many implemented features, and a
set of changes to Django itself (that
don't break anything else of course)
that enable this.
http://groups.google.com/group/django-developers/browse_thread/thread/36ed23d7b32ff0fd?pli=1
So if you want to use MongoDB with the Django ORM you can switch to django-norel and use django-mongodb-engine or you can wait for Alex's work to be merged into the trunk.
We use django-mongodb-engine in production and we haven't face any performance issues. It is well known that using django-mongodb-engine means that you'll be tight to the django ORM, checks, fields and so on. But, you're also able to execute raw queries when you simply don't care about django ORM.
django-mongodb-engine started taking some ideas from opensource projects (mongodbengine is one of those)
P.S: One of the things I like more about django-mongodb is the easy integration with django because it allow you to simply switch the DB when you need it (Unless you're using "non-standard fields")
P.S2: I'll open a issue requesting some benchmarks
Update: The issue link

CodeIgniter & Datamapper as frontend, Django Admin as backend, database tables inconsistent

I created a database for a site i'm doing using Django as the admin backend. However because the server where the site is hosted on, won't be able to support Python, I find myself needing to do the front end in PHP and as such i've decided to use CodeIgniter along with Datamapper to map the models/relationship.
However DataMapper requires the tables to be in a specific format for it to work, and Django maps its tables differently, using the App name as the prefix in the table. I've tried using the prefix & join_prefix vars in datamapper but still doesn't map them correctly.
Has anyone used a combination of this? and if so how have the fixed the issue of db table names being inconsistent? Is there anything out there that i can use to make them work together?
----edit: clarification on backend---
Let me clarify: i'm going to be running the admin from a subdomain pointing to a python ready server. However i can't move the main domain name from the php only webserver because of certain constraints/binding contracts the company got itself in. and don't want to use cloaking/masking because of seo purposes.
i'm using the django admin because i'm using some packages to make a pretty/functional admin, such as grappelli for the admin template, along with its editor for editing news stories, etc. also using photologue to manage photos/galleries. etc.
If your problem is simply making Django use the same tables as your other software, use the db_column and db_table parameters in the models.
http://www.djangoproject.com/documentation/models/custom_columns/
Two apparent solutions:
Instead of hacking one or both to work well with each other, emulate the Django admin in PHP/CodeIgniter code. **
Get a server that supports Django. Make the frontend in Django.
Time-wise, either one of those solutions will be less involving than trying to make two different frameworks using different programming languages mesh well together. I can't imagine the future maintenance required to ensure everlasting compatibility and interoperability.
Also, I assume by saying:
I created a database for a site i'm doing using Django as the admin backend
You really mean that you modeled your apps using Django, and that you also intend on administrating the database that has resulted from this modeling in the Django admin. (In which case you already have your Models layer complete and should just try building the rest of the site in Django)
If that's the case then in your models you are going to need to define the exact column names (db_column) that DataMapper will expect, as well as manually define the table names (db_table), including M2M tables.
You may also have to define all of your primary keys manually, if DM expects something named differently.
Also:
If the server can't support Python, where are you going to be running your backend? Different server? Locally? This plan just isn't making a lot of sense.
** I would not suggest trying this. I had been attempting to make a CI backend that actually shared much of the same ideas as Django's admin, before I knew about Django's admin. And of course once discovering Django, I dropped the CI work immediately and continued on with what I have found to be a much more amazing framework that is much faster to develop on.
So as I understand you plan on using Django just because of django-admin, and you are trying to use CI for the actual site because the server runs PHP, right?
So why don't you use framework that generates something like Django's admin but that you can run on your server?
The Symfony Framework has a really nice admin generator, in the spirit of Django's and you might be able to run it on your server. This would save you from the maintainance nightmare that might come later as #jonwd7 answered