我无法在本地运行我的 Django 服务器。我正在尝试设置我的djongo数据库而不是默认的sqlite3 .db
在这里,我在 python设置上按照以下 djongo djongo 的 URL
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fb554b61bf8>
Traceback (most recent call last):
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 442, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations
if self.has_table():
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 56, in table_names
return get_names(cursor)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 51, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/djongo/introspection.py", line 34, in get_table_list
for c in cursor.db_conn.collection_names(False)]
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/database.py", line 715, in collection_names
nameOnly=True, **kws)]
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/database.py", line 674, in list_collections
read_pref) as (sock_info, slave_okay):
File "/home/iradmin/anaconda3/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1099, in _socket_for_reads
server = topology.select_server(read_preference)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/topology.py", line 224, in select_server
address))
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/topology.py", line 183, in select_servers
selector, server_timeout, address)
File "/home/iradmin/anaconda3/lib/python3.6/site-packages/pymongo/topology.py", line 199, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
在这里,我包含了我的 setting.py 供您参考。
DATABASES = {
'default' : {
'ENGINE' : 'djongo',
'NAME' : 'my_database'
}
}
INSTALLED_APPS = [
'polls',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]