配置 neo4j django-neomodel 时出错
Errors during configuration of the neo4j django-neomodel
我正在尝试使用 Neo4j 数据库在 Django 中做一个简单的项目。我安装了一个django-neomodel
库,设置如下:
import os
from neomodel import config
db_username = os.environ.get('NEO4J_USERNAME')
db_password = os.environ.get('NEO4J_PASSWORD')
config.DATABASE_URL = f'bolt://{db_username}:{db_password}@localhost:7687'
创建了一个模型:
class Task(StructuredNode):
id = UniqueIdProperty()
title = StringProperty()
将 'django_neomodel'
添加到 INSTALLED_APPS
,删除了默认数据库配置,当我尝试进入网站时出现错误:ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
.
这是唯一的错误,因为在 运行 之后它引发了 python manage.py install_labels
命令:ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error)) neo4j.exceptions.ServiceUnavailable: Failed to establish connection to IPv6Address(('::1', 7687, 0, 0)) (reason [Errno 99] Cannot assign requested address)
.
我很确定数据库可以正常工作,因为如您所见,我可以访问它。 screenshot
docker-撰写:
version: "3.9"
services:
api:
container_name: mm_backend
build:
context: ./
dockerfile: Dockerfile.dev
command: pipenv run python manage.py runserver 0.0.0.0:8000
volumes:
- ./:/usr/src/mm_backend
ports:
- 8000:8000
env_file: .env
depends_on:
- db
db:
container_name: mm_db
image: neo4j:4.1
restart: unless-stopped
ports:
- "7474:7474"
- "7687:7687"
volumes:
- ./db/data:/data
- ./db/logs:/logs
好吧,经过一些研究我发现了这个 post 问题已经解决了。
我正在尝试使用 Neo4j 数据库在 Django 中做一个简单的项目。我安装了一个django-neomodel
库,设置如下:
import os
from neomodel import config
db_username = os.environ.get('NEO4J_USERNAME')
db_password = os.environ.get('NEO4J_PASSWORD')
config.DATABASE_URL = f'bolt://{db_username}:{db_password}@localhost:7687'
创建了一个模型:
class Task(StructuredNode):
id = UniqueIdProperty()
title = StringProperty()
将 'django_neomodel'
添加到 INSTALLED_APPS
,删除了默认数据库配置,当我尝试进入网站时出现错误:ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
.
这是唯一的错误,因为在 运行 之后它引发了 python manage.py install_labels
命令:ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error)) neo4j.exceptions.ServiceUnavailable: Failed to establish connection to IPv6Address(('::1', 7687, 0, 0)) (reason [Errno 99] Cannot assign requested address)
.
我很确定数据库可以正常工作,因为如您所见,我可以访问它。 screenshot
docker-撰写:
version: "3.9"
services:
api:
container_name: mm_backend
build:
context: ./
dockerfile: Dockerfile.dev
command: pipenv run python manage.py runserver 0.0.0.0:8000
volumes:
- ./:/usr/src/mm_backend
ports:
- 8000:8000
env_file: .env
depends_on:
- db
db:
container_name: mm_db
image: neo4j:4.1
restart: unless-stopped
ports:
- "7474:7474"
- "7687:7687"
volumes:
- ./db/data:/data
- ./db/logs:/logs
好吧,经过一些研究我发现了这个 post