2013-02-22 3 views
2

현재 Django 1.4.3을 실행 중이며 MongoLab에서 만든 자체 데이터베이스를 연결하여 Django 웹 사이트와 대화하고 싶습니다. 나는 그것을 달성하는 방법에 대한 많은 자습서를 따라 시도했다; 내 Django settings.py 파일에서 실행중인 문제는 내 데이터베이스가 올바르게 설정되지 않았다는 것입니다 (연결할 수 없기 때문입니다). 나는 Django와 MongoDB에 대해 매우 익숙하다. 그래서 어떤 도움을 주시면 감사하겠습니다. http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-releasedMongoLab 데이터베이스에 Django를 연결하십시오.

참고 :

는 여기에 내가 다음에 한 자습서 중 하나입니다 내가 Mac을 사용하고이 문제의 경우 모든 프로그램 터미널을 사용하고 있습니다.

Validating models... 

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10f732210>> 
Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run 
self.validate(display_num_errors=True) 
    File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 266, in validate 
num_errors = get_validation_errors(s, app) 
    File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 23, in get_validation_errors 
from django.db import models, connection 
    File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 40, in <module> 
backend = load_backend(connection.settings_dict['ENGINE']) 
    File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 34, in __getattr__ 
return getattr(connections[DEFAULT_DB_ALIAS], item) 
    File "/Library/Python/2.7/site-packages/django/db/utils.py", line 92, in __getitem__ 
backend = load_backend(db['ENGINE']) 
    File "/Library/Python/2.7/site-packages/django/db/utils.py", line 24, in load_backend 
return import_module('.base', backend_name) 
    File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module 
__import__(name) 
    File "build/bdist.macosx-10.8-intel/egg/django_mongodb_engine/__init__.py", line 13, in <module> 
AttributeError: 'tuple' object has no attribute 'insert' 

파일 : .../django_mongodb_engine/여기

(대부분의 장고에 의해 자동 생성 된) 다음
DATABASES = { 
    'default': { 
     #'ENGINE': 'django_mongodb_engine', ### This wasn't working ### 
     'ENGINE': '', 
     'NAME': '',      # Or path to database file if using sq$ 
     'USER': '',      # Not used with sqlite3. 
     'PASSWORD': '',     # Not used with sqlite3. 
     'HOST': '',      # Set to empty string for localhost. N$ 
     'PORT': '',      # Set to empty string for default. Not$ 
    } 
} 

오류 메시지가 내 settings.py의 문제 영역입니다 init
.py (바로 다운로드 할 수 있음, 편집하지 않음)

#!/usr/bin/python 
# -*- coding: utf-8 -*- 

__version__ = (0, 4, 0) 
__author__ = "Flavio Percoco Premoli, Alberto Paro, " + \ 
     "Jonas Haag and contributors" 
__contact__ = "[email protected]" 
__homepage__ = "https://django-mongodb.org" 
__docformat__ = "restructuredtext" 

try: 
    from django.conf import settings 
    settings.INSTALLED_APPS.insert(0, 'django_mongodb_engine') 
    # It might be irritating that django-mongodb-engine registers itself as an app, 
    # and I think this is worth an explanation - so here you go: 
    # django-mongodb-engine provides a way to set MongoDB-specific options for a 
    # certain model via the 'MongoMeta' class/attribute (similar to the Django-style 
    # 'Meta' class). We want those options to be copied into the model's 
    # '_meta' object, right after the class has been defined. 
    # For this, we have to listen to the 'class_prepared' signal from 
    # 'django.db.models.signals'. Because the 'django_mongodb_engine' module gets 
    # imported as part of the initialization process of Django's ORM ('django.db'), 
    # we can *not* import anything from 'django.db' in this file (or any other 
    # submodule that is imported while the ORM initialization) because that would 
    # get us into recursive import hell which the Python interpreter doesn't allow. 
    # The only way to make sure certain code is executed after Django's ORM has been 
    # initialized is registering an app. After initializing itself, Django imports 
    # all apps defined in the project's 'settings.py' in the order implied by 
    # iterating over the INSTALLED_APPS list. As we have to make sure that 
    # django-mongodb-engine is loaded very first, we prepend it to the list. 
except ImportError: 
pass 
+0

settings.py를 게시하고 전체 오류를 게시 할 수 있습니까? – dm03514

+0

그냥 주로 장고에서 자동 생성되었지만 –

+0

오류 메시지를 게시하십시오. –

답변

2

버그가있는 것 같습니다.

체크 this report. 당신이 링크를 따라하는 경우

는 그리고, here 개발자는 말한다 :

MongoDB의 엔진이 시간에 장고 1.4을 지원하지 않습니다. 그래서 1.3을 붙이십시오.

댓글은 어제에서 온 것입니다. 이제 Django 버전은 호환되지 않습니다.

2

설정 파일에서 값을 구성해야합니다. 보시다시피 이들은 대부분 빈 문자열입니다. MongoLab은 사용자가 생성 한 데이터베이스의 홈 페이지에서 필요한 모든 연결 정보를 제공합니다.

+0

나는 그 모든 값을 가지고 있습니다. "django_mongodb_engine"을 통해 연결할 수 없습니다. 왜 연결되지 않을지 모르겠습니다. –

+0

Stacktrace와 함께 나타나는 오류 메시지를 게시 할 수 있습니까? (모든 암호를 모호하게) – will

+0

게시 됨 오류 메시지 –

관련 문제