0

我按照入门settings.py中的指示进行了这些设置:

NEOMODEL_NEO4J_BOLT_URL = os.environ.get('NEO4J_BOLT_URL', 'bolt://neo4j:password@localhost:7687')
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_neomodel',
    'utils'
]

但我只得到这个错误python manage.py install_labels

neo4j.exceptions.ServiceUnavailable: [SSLCertVerificationError] Connection Failed. Please ensure that your database is listening on the correct host and port and that you have enabled encryption if required. Note that the default encryption setting has changed in Neo4j 4.0. See the docs for more information. Failed to establish encrypted connection. (code 1: Operation not permitted)

我知道数据库和 neomodel 都可以,因为neomodel_install_labels models.py --db bolt://neo4j:password@localhost:7687可以完美运行并在数据库上创建节点。

我不知道在哪里可以找到这个异常的来源。

4

2 回答 2

0

好吧,我发现,只是通过尝试不同的事情,我必须config.py在 django 上设置所有 neomodels 的变量settings.py

NEOMODEL_NEO4J_BOLT_URL = 'bolt://neo4j:password@localhost:7687'
NEOMODEL_SIGNALS = True
NEOMODEL_FORCE_TIMEZONE = False
NEOMODEL_ENCRYPTED_CONNECTION = False
NEOMODEL_MAX_CONNECTION_POOL_SIZE = 50
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_neomodel',
    'utils'
]

它终于奏效了。

于 2020-12-26T18:40:05.817 回答
0

从新模型设置:

NEOMODEL_NEO4J_BOLT_URL = 'bolt://neo4j:neo4j@localhost:7687'
NEOMODEL_SIGNALS = True
NEOMODEL_FORCE_TIMEZONE = False
NEOMODEL_ENCRYPTED_CONNECTION = True
NEOMODEL_MAX_POOL_SIZE = 50

您可以看到加密设置为True,这很可能是错误消息所说的(我怀疑您的本地 Neo4j 已启用加密)。

我只是将加密设置为 False :

NEOMODEL_ENCRYPTED_CONNECTION = False
于 2020-12-26T18:27:55.110 回答