NeoDjango¶
Integrating your Django project with the all features of Neo4j.
Why Django?¶
Why Neo4j?¶
Contents:
The PRIMARY AUTHORS are:
- Renan Palmeira <renanpalmeira1@hotmail.com>
Getting Started¶
Installation¶
Install NeoDjango with your favorite Python package manager:
$ pip install neodjango
Downloaded and run Neo4j
Configuration¶
Once you’ve installed neodjango and configure your Django project for connect to Neo4j.
Database Setup
An example settings.py:
INSTALLED_APPS = (
# other apps
"neodjango",
)
NEO4J_DATABASES = {
'default' : {
'HOST':'localhost',
'PORT':7474,
'ENDPOINT':'/db/data'
}
}
Nodes¶
Model¶
Writing nodes.py
from neodjango.db import models
- class Label(models.Model):
- class Meta:
display = “name”
Querying¶
Retrieving all objects
>>> Label.objects.all() [<Node#id: property>, <Node#id: property>, <Node#id: property>, <Node#id: property>]
Retrieving specific objects with filters
>>> Label.objects.filter(name='Guido') [<Node#id: property>,]
Retrieving a single object with get
>>> Label.objects.get(name='Lawrence') <Node#id: property>
>>> Label.objects.get(id=42) <Node#id: property>
Retrieving all relationships of objects
>>> Label.objects.get(name='Ken Thompson').relationships()
>>> Label.objects.get(name='Emil Eifrem').Created()