I am trying to use a neo4j
database on a django
website hosted on a Apache
server. I am using neo4django
. I have followed the instruction given in http://neo4django.readthedocs.org/en/v0.1.8/index.html. when creating a node, I get the following error:
error at /disk/ [Errno 111] Connection refused Request
My models.py:
import django.db
from neo4django.db import models
class Person(django.db.models.Model):
name = django.db.models.CharField(max_length=50, null=True, blank=True)
username = django.db.models.CharField(max_length=50, null=True, blank=True)
password=django.db.models.CharField(max_length=50, null=True, blank=True)
email=django.db.models.CharField(max_length=50, null=True, blank=True)
class Meta:
db_table='lt_profile'
class Pnode(models.NodeModel):
name=models.StringProperty()
#more fields
class Anode(models.NodeModel):
art_type=models.StringProperty(max_length=50)
mtime=models.StringProperty(max_length=200)
#relation:
My settings.py:
NEO4J_DATABASES = {
'default' : {
'HOST':'localhost',
'PORT': 7474,
'ENDPOINT':'/var/www/graph_db'
}
}
DATABASE_ROUTERS = ['neo4django.utils.Neo4djangoIntegrationRouter']
Code where the error happens:
a = Anode.objects.create(art_type='py', mtime=str(file_mtime))
a.save()
I think I need to change something in my port.conf
file in Apache ,but I don't know what I should do. I have tried things like:
Listen 7474 in the ports.conf
, but no luck. Any help will be appreciated. Thanks
@Wes is right in the comments- your endpoint should be set to a relative URL, not a file path.
From the docs, try 'ENDPOINT':'/db/data'
, which is the default for Neo4j.
EDIT:
Some other bits of advice:
You definitely don't need to add anything in your Apache config. Apache serves up your content from Django, but doesn't control which ports you can access from Django- its config files only cover which ports external users can access. In fact, if Apache is configured to listen on 7474 and it's on the same server as Neo4j, one of them won't be able to use the port.
In your code, you use a = Anode.objects.create(...)
followed by a.save()
. Anode.objects.create()
is a shortcut for
a = Anode(...)
a.save()
so you're actually saving twice. I'd use one or the other to avoid hitting the database more often than necessary.