djangomongodbherokudjango-nonreldjango-mongodb-engine

Django + MongoDB on Heroku


I'd like to use Django with MongoDB on Heroku. In the their document, Getting Started with Django on Heroku/Cedar : Postgres Database Config, says that some code is appended to settings.py to use the DATABASE_URL.

Is there any way to avoid this ? Because the DATABASES needs to be django_mongodb_engine here, also with other settings, e.g. (example dragged from compSocSci)

DATABASES = {
  'default': {
    'ENGINE': 'django_mongodb_engine',
    'NAME': 'heroku_app1234567',
    'USER': 'heroku_app1234567',
    'PASSWORD': 'abcdefghijklmnopqrstuvwxyz',
    'HOST': 'ds031117.mongolab.com',
    'PORT': '31117',
  }
}

Solution

  • Ok so I have figured out the way to do this after contact to Heroku support.
    All you have to do is remove the shared PostgreDB addon and the injected code
    would not modify the DATABASES.

    $ heroku addons:remove shared-database:5mb
    

    And note that you still need to include psycopg2 in your requirements.txt.