I am working on a web app. For the backend I chose Django and as a database I would like to use a graph database so I chose neo4j.
There is a python library neomodel
to work with neo4j and a specific library django_neomodel
to incorporate neomodel
with Django.
I am able to use Django to with neo4j to retrieve data from a node in the database, however I cannot get it to create a node in the database.
Here is my a part of my settings.py
file:
INSTALLED_APPS = [
...
'django_neomodel',
'neomodel',
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_simplejwt',
'create',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
}
NEOMODEL_NEO4J_BOLT_URL = 'bolt://neo4j:password@localhost:7687'
and here the views.py
from create
class RegisterView(View):
"""
This view handles POST requests to create a new user in the database.
"""
def post(self, request):
new_node = myNode(XXX=request.POST['XXX'], YYY=request.POST['YYY'], ZZZ=request.POST['ZZZ'])
new_nodesave()
Here the myNode
class:
from neomodel import (StructuredNode,
StringProperty,
UniqueIdProperty)
from .event import Event
class myNode(StructuredNode):
# Properties
uid = UniqueIdProperty()
XXX = StringProperty(required=True, unique_index=True)
YYY = StringProperty(required=True)
ZZZ = StringProperty(required=True)
The error I get is:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
I asked chatGPT and github copilot and got the response that I can just set a dummy ENGINE in the settings like so
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy'
}
}
But this does not help.
Does anyone have a clue? I looked for documentations but all I can find are these tutorials to use the Panama papers database with neo4j and Django (like here, but there they also just access the database but never create new nodes, relationships or change them in any way.
Is that even possible? Or do I need to create an engine myself?
I use djangorestframework 3.15.1
, neomodel 5.3.1
and neo4j 4.4.34
I am new to app development. I have just started and chose Django just because python is the language I know best, so please if you answer write for a complete newbi