0

こんにちは、よろしくお願いします。PythonとDjangoの学習を始めたばかりで、djangoproject.comでチュートリアルを設定しようとしています。サーバーをセットアップしようとしましたが、次のエラーが発生し続けます。

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x108826090>>
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 44, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.sqlite3.db' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named sqlite3.db.base

スポットライトを使用してsqlite3.db.baseを見つけようとしましたが、そのモジュールが見つかりません。ターミナルに移動してsysをインポートし、sqlite3をインポートしても、エラーは発生しません。ターミナルのSys.pathは私に与えます:

['', 
'/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg', 
'/Library/Python/2.7/site- packages/distribute-0.6.27-py2.7.egg',   
'/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', 
'/Library/Python/2.7/site-packages', 
'/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']

現在、settings.pyは次のように設定されています。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.sqlite3.db', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',      # 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.
    }
}

再度、感謝します!

4

2 に答える 2

9

設定を壊しましたENGINE。する必要がありますdjango.db.backends.sqlite3

于 2012-06-19T18:48:47.860 に答える
1

それは輸入についてではありません。ENGINE設定でタイプミスしました。次のようにする必要があります。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.                                                              
        'NAME': join(CURRENT_DIR, 'db/cms.db'), # 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.                                                                        
    }
}
于 2012-06-19T18:51:14.363 に答える