如何在settings.py中为tastypie mongoengine配置django?

时间:2012-11-25 08:51:53

标签: django tastypie mongoengine

我刚刚开始构建restful api。 我开始项目烹饪并为api创建应用程序。 我使用tastypie和tastypie-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吗? 如何配置正确? 感谢提前

1 个答案:

答案 0 :(得分:0)

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

阅读MongoEngine关于如何将其与Django集成的文档。