현재 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
settings.py를 게시하고 전체 오류를 게시 할 수 있습니까? – dm03514
그냥 주로 장고에서 자동 생성되었지만 –
오류 메시지를 게시하십시오. –