Hick
Hick

Reputation: 36414

Mongo DB or Couch DB with django for building an app that is similar to top coder?

This is what I have :-

  1. Ubuntu 11.10.
  2. Django 1.3
  3. Python 2.7

What I want to do is build an app that is similar to top-coder and I have the skeletal version of the app sketched out. The basic requirements would be:- 1. Saving the code. 2. Saving the user name and ranks.(User-profile) 3. Should allow a teacher to create multiple choice questions too.( Similar to Google docs).

I have basic knowledge of Django and have built couple of (basic) apps before. Rather than building an online tool, is it possible to build something very similar to conf2py that sits on top of web2py, in Django.

Lets call this small project examPy( I know, very original), is it possible to build an app that acts more a plug-in to Django or is my concept of Django absolutely wrong?

The primary question being: As I want to learn a new DB and have worked on postgres in Django, should I chose CouchDB or MongoDB for Django?

Answers can be explanations or links to certain documentations or blogs that can tell me the pros and cons.

Upvotes: 3

Views: 2639

Answers (3)

nialloc
nialloc

Reputation: 850

I've used mongo-engine with Django but you need to create a file specifically for Mongo documents eg. Mongo_models.py. In that file you define your Mongo documents. You then create forms to match each Mongo document. Each form has a save method which inserts or updates whats stored in Mongo. Django forms are designed to plug into any data back end ( with a bit of craft ).

If you go this route you can dodge Django non-rel which is still not part of Django 1.4. In addition I believe django-nonrel is on hiatus right now.

I've used both CouchDB and Mongo extensively. CouchDB has a lovely interface. My colleague is working on something similar for Mongo. Mongo's map and reduce are far faster than CouchDB. Mongo is more responsive loading and retrieving data. The python libraries for Mongo are easier to get working with ( both pymongo and mongo-engine are excellent )

Be sure you read the Mongo production recommendations! Do not run one instance on the same node as Django or prepare to be savagely burned when traffic peaks. Mondo works great with Memcache/Redis where one can store reduced data for rapid lookups.

BEWARE: If you have very well defined and structured data that can be described in documents or models then don't use Mongo. Its not designed for that and something like PostGreSQL will work much better.

  • I use PostGreSQL for relational or well structured data because its good for that. Small memory footprint and good response.
  • I use Redis to cache or operate in memory queues/lists because its very good for that. great performance providing you have the memory to cope with it.
  • I use Mongo to store large JSON documents and to perform Map and reduce on them ( if needed ) because its very good for that. Be sure to use indexing on certain columns if you can to speed up lookups.

Don't use a circle to fill a square hole. It won't fill it.

Upvotes: 3

emperorcezar
emperorcezar

Reputation: 331

I've used CouchDB with Django for a production application. Couch is fine and has some great ideas, but I'm moving that app over to MongoDB. Why? There is support for Mongo in the Django community. Django-nonrel has a MongoDB backend. Using Django-toolbox I can embed models in models and have some basic admin support.

If I remember correctly, Django-nonrel will eventually be rolled into Django core. In five years time I see much more support for Mongo in Django than Couch. Of course that can change, but I see Mongo a better fit.

Upvotes: 2

Cody Hess
Cody Hess

Reputation: 1796

General Differences

Django Specific

All my research points me towards the idea that Mongo and Couch are similar enough that your choice would probably boil down to personal (subjective) preference even over the use-case. Personally, I've developed a CouchDB fetish and am looking for a reason to use it.

The key factor influencing your decision should probably be which noSQL solution has the most mature ORM framework for Django?

Upvotes: 3

Related Questions