django-heroku-mongoify

django-heroku-mongoify provides a user-friendly method to configure Django projects on Heroku to use MongoDB.

Inspired by the work of Randall Degges.

Installation

To install the latest version of django-heroku-mongoify:

$ pip install django-heroku-mongoify

or, if you must:

$ easy_install django-heroku-mongoify

To install the latest development version:

$ git clone git@github.com:dirn/django-heroku-mongoify.git
$ cd django-heroku-mongoify
$ python setup.py install

Usage

In settings.py:

from mongoify import mongoify
from pymongo import MongoClient
db = MongoClient(mongoify(default='mongodb://localhost/test')['default'])

API

Friendly MongoDB for Django on Heroku

mongoify.mongoify(default=None)

Returns a dictionary of URIs based on environment settings.

This method will look for MongoDB URI connection strings in the environment settings. It will first check for MONGO_URI. If this setting is found, it will be in the result dict as the default key. The method will then iterate through the settings looking for any additional URI connection strings. Any that are found will be added to the result dict.

In the event that MONGO_URI was not found, the first URI connection string encountered will be used as the default key. This URI will appear twice.

In the event that MONGO_URI was not found and no other URI connection strings were found, the value provided through the default argument will be used as the default key.

If default was no provided and no other URI connection strings were found, the dict will be empty.

Parameters:default (str.) – A connection string URI for a MongoDB database.
Returns:dict – connection string URIs that can be used with pymongo.MongoClient.

Changed in version 0.2.0: mongoify() now returns a dict containing all URIs

New in version 0.1.0.

Further Reading

More information about URI connection strings can be found in the MongoDB Docs.

Changelog

  • 0.2.0: - THIS RELEASE IS NOT BACKWARDS COMPATIBLE - mongoify() now returns a dict of all URIs found in the environment settings.
  • 0.1.0: - Initial release

Indices and tables

Table Of Contents

This Page