【问题标题】:how to config django for tastypie mongoengine in settings.py?如何在settings.py 中为tastepie mongoengine 配置django?
【发布时间】:2012-11-25 08:51:52
【问题描述】:

我刚刚开始构建restful api。 我开始项目烹饪并创建应用程序到 api。 我使用了美味派和美味派-mongoengine 插件。 在 settings.py 我这样配置

INSTALLED_APPS +=('tastypie',
'tastypie_mongoengine',
'django.contrib.sessions')
MIDDLEWARE_CLASSES += ('django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',)
    import mongoengine
mongoengine.connect('cooking')
AUTHENTICATION_BACKENDS = (
    'mongoengine.django.auth.MongoEngineBackend',
    )
SESSION_ENGINE = 'mongoengine.django.sessions'

我对此发表评论

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
#        'NAME': '', # Or path to database file if using sqlite3.
#        'USER': '', # Not used with sqlite3.
#        'PASSWORD': '', # Not used with sqlite3.
#        'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
#        'PORT': '', # Set to empty string for default. Not used with sqlite3.
#    }
#}

但是当我同步它时django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. 我也想让 django 项目使用 mongo 吗? 如何正确配置? 感谢提前

【问题讨论】:

    标签: django tastypie mongoengine


    【解决方案1】:

    如果您不使用关系数据库,则不应运行 syncdb

    阅读MongoEngine 的文档,了解如何将其与 Django 集成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-26
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 2015-03-03
      相关资源
      最近更新 更多