-->

Trouble using MongoDB as backend for Django projec

2019-03-02 09:23发布

问题:

I set up my app using the following tutorial, http://django-mongodb-engine.readthedocs.org/en/latest/topics/setup.html When I set my backend as detailed in this link in my settings.py, I get the following error:

NotImplementedError: subclasses of BaseDatabaseIntrospection may require
a  get_table_list() method

I have installed all the necessary packages (django-nonrel, djangotoolbox, mongodb-engine), but I'm still getting these errors. What might I be doing wrong/am I missing? It could very likely be something trivial-- I'm new to Django and MongoDB.

My DATABASES setting is as follows,

DATABASES = {
   'default' : {
      'ENGINE' : 'django_mongodb_engine',
      'NAME' : 'example_db'
   }
}

and my INSTALLED_APPS are as follows,

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mongoadmin',
    'mongoengine.django.mongo_auth',
    'polls', 
)

Thank you!

回答1:

django-mongo-db-engine does not work with Django 1.7. It uses Django-nonrel, (a fork of Django) instead of Django.

Try creating your dev environment again, but this time, do not install Django 1.7.